# signature { license=0, seed=277031123, key="7fcca759fd5ca713e004a9b95ebbd576" }
cgi.print([[]],cgi.head,[[
<title>InLMS ]],i18n("Configuration"),[[</title>
<script src="cfg.js" type="text/javascript" ></script>
<script>
function dom( x ) { return document.getElementById( x ) }

function askRestore(filename)
{
	var txt = "]],i18n("You are about to upload the file {filename} as new InLMS configuration\\nContinue ?"),[[";
	txt = txt.replace("{filename} ", '\n"'+ filename +'"\n');
	if (window.confirm(txt) )
		document.putcfg.submit();
	return false;
}

var cfg =]],cfg:JSON(),[[;

function GET (url)
{
	objHTTP = new XMLHttpRequest();
	objHTTP.open( "GET", url, false, "]],cfg.XmlProUserID,[[", "]],cfg:password('XmlPro'),[[" );
	objHTTP.send();
	return ""+ objHTTP.responseText;
}

function forConfig( f )
{
	for (var name in cfg)
	{
		var item = cfg[ name ];
		var e = document.getElementsByName( name );
		if (e && e[0]) f( e[0], item, name );
	}
}

function send()
{
	var s = '';

	function changeNote( e, item, name)
	{
		var v;
		switch (e.tagName)
		{
			case 'INPUT': v = e.value; break;
			case 'SELECT':v = e.selectedIndex;
				if (v<0) return;
				v = e.options[ v].value;
		};
		switch (typeof item )
		{
			case 'number':	s += name +'='+ (v-0) +";\n"; break;
			case 'string':	s += name +'="'+ v.replace(/\\/g,"\\\\").replace(/"/g,"\\\"") +'";\n';  break;
			case 'boolean':	s += name + (v ? '=true;\n' : '=false;\n'); break;
		}
	}

	forConfig( changeNote );

	document.xfer.change.value = s;
	document.xfer.submit();
}

function fetch()
{
	if ( window.confirm( "]],i18n("Updating the licence data may cause a reset of the IPLE card within the PBX that will cause active calls for all VoIP device to disconnect (VoIP Trunks and Extensions)") ,[[") )
	{
		window.location.href = 'lms.cgi?cmd=poll';
	}
}

var MsgBox="]],MsgBox or '',[[";
function start()
{
	init()
	if (MsgBox && MsgBox > '') alert( MsgBox ) ;
}

</script>
</head>
<body onload="start()">]],cgi.h1,[[
<div class="body">
	<h2>]],i18n("Configuration"),[[
		]],cgi.button{ title=i18n("save changes in configuration"), href="javascript:send()", img="../ok.png", i18n("Ok")},[[
		]],cgi.button{ title=i18n("trigger a license renewal"), href="javascript:fetch()", img="../refresh.png", i18n("Fetch")},[[
	</h2>
	<h3>]],i18n("Files"),[[</h3>
	<div class="icons" >
		]],cgi.icon{ title=i18n("download a copy of the configuration file"), href="lms.cgi?cmd=getcfg", img="backup.png", i18n("Backup") },[[

		<form name="putcfg" action="lms.cgi?cmd=putcfg" method="post" enctype="multipart/form-data">
			<a class="icon"><img alt="" src="restore.png" />]],i18n("Restore"),[[
				<div class="upload">
					<input type="file" id="cfgfile" name="cfgfile" onchange="askRestore(this.value)"
						title="]],i18n("upload a (previously backed up) configuration file"),[[" />
				</div>
			</a>
		</form>

		]],cgi.icon{ title=i18n("read the application's log file"), href="lms.cgi?cmd=viewlog", img="viewlog.png", i18n("Logfile") },[[

		]],cgi.icon{ title=i18n("download a text file for localisation"), href="lms.cgi?cmd=geti18n", img="langdn.png", i18n("Get Texts") },[[

		<form name="puti18n" action="lms.cgi?cmd=puti18n" method="post" enctype="multipart/form-data">
			<a class="icon"><img alt="" src="langup.png" />]],i18n("Localise"),[[
				<div class="upload">
				<input type="file" id="i18nfile" name="i18nfile" onchange="setTimeout('document.forms.puti18n.submit()',10)"
					title="]],i18n("upload a localised text file"),[[" />
				</div>
			</a>
		</form>
	</div>

	<h3>]],i18n("XmlPRO / WebPRO Settings"),[[</h3>
	<form id="confTable">
	<ul class="cfg">
		<li><input name="XmlProUserID"   type="text"     size="30" maxlength="10" value="" /> ]],i18n("Username"),[[</li>
		<li><input name="XmlProPassword" type="password" size="30" maxlength="8"  value="" /> ]],i18n("Password"),[[</li>
	</ul>

	<h3>]],i18n("LMS Settings"),[[</h3>
	<ul class="cfg">
		<li><input name="LMServerURL"    type="text"     size="30" maxlength="80"  value="" /> ]],i18n("Server URL"),[[</li>
		<li><input name="AuthServerURL"  type="text"     size="30" maxlength="80"  value="" /> ]],i18n("Authentication URL"),[[</li>
		<li><input name="DeviceId"       type="text"     size="30" maxlength="80"  value="" readonly /> ]],i18n("Device ID"),[[</li>
		<li><input name="SwVersion"      type="text"     size="30" maxlength="50"  value="" readonly /> ]],i18n("Main Software Version"),[[</li>
		<li><input name="updateKey"      type="text"     size="30" maxlength="50"  value="" readonly /> ]],i18n("Last License ID"),[[</li>
		<li><select name="requestTimeRange" size="1" maxlength="50">
				<option value="-1">]],i18n("As set by LMS"),[[</option>
				<option value="0">]],i18n("0:00 - 0:59"),[[</option>
				<option value="1">]],i18n("1:00 - 1:59"),[[</option>
				<option value="2">]],i18n("2:00 - 2:59"),[[</option>
				<option value="3">]],i18n("3:00 - 3:59"),[[</option>
				<option value="4">]],i18n("4:00 - 4:59"),[[</option>
				<option value="5">]],i18n("5:00 - 5:59"),[[</option>
				<option value="6">]],i18n("6:00 - 6:59"),[[</option>
				<option value="7">]],i18n("7:00 - 7:59"),[[</option>
				<option value="8">]],i18n("8:00 - 8:59"),[[</option>
				<option value="9">]],i18n("9:00 - 9:59"),[[</option>
				<option value="10">]],i18n("10:00 - 10:59"),[[</option>
				<option value="11">]],i18n("11:00 - 11:59"),[[</option>
				<option value="12">]],i18n("12:00 - 12:59"),[[</option>
				<option value="13">]],i18n("13:00 - 13:59"),[[</option>
				<option value="14">]],i18n("14:00 - 14:59"),[[</option>
				<option value="15">]],i18n("15:00 - 15:59"),[[</option>
				<option value="16">]],i18n("16:00 - 16:59"),[[</option>
				<option value="17">]],i18n("17:00 - 17:59"),[[</option>
				<option value="18">]],i18n("18:00 - 18:59"),[[</option>
				<option value="19">]],i18n("19:00 - 19:59"),[[</option>
				<option value="20">]],i18n("20:00 - 20:59"),[[</option>
				<option value="21">]],i18n("21:00 - 21:59"),[[</option>
				<option value="22">]],i18n("22:00 - 22:59"),[[</option>
				<option value="23">]],i18n("23:00 - 23:59"),[[</option>
			</select> ]],i18n("License update time"),[[
		</li>
	</ul>


	<h3>]],i18n("Email Sending (SMTP) Settings"),[[</h3>
	<ul class="cfg">
		<li><input name="SmtpServer"     type="text"     size="30" maxlength="80" value="" /> ]],i18n("Name or IP address of the SMTP Server"),[[</li>
		<li><input name="SmtpPort"       type="text"     size="30" maxlength="5" value="" /> ]],i18n("TCP Port for SMTP"),[[</li>
		<li><input name="SmtpUsername"   type="text"     size="30" maxlength="50"  value="" /> ]],i18n("SMTP Username"),[[</li>
		<li><input name="SmtpPassword"   type="password" size="30" maxlength="30"  value="" /> ]],i18n("SMTP Password"),[[</li>
		<li><input name="EmailFrom"      type="text"     size="30" maxlength="80"  value="" /> ]],i18n("Sender Address"),[[</li>
		<li><select name="SmtpSecurity" size="1" maxlength="50">
				<option value="0">]],i18n("StartTLS"),[[</option>
				<option value="1">]],i18n("SSL/TLS"),[[</option>
			</select> ]],i18n("transport encryption"),[[
		</li>
	</ul>
	</form>
</div>
<form name="xfer" action="lms.cgi?cmd=cfghome" method="post">
	<input type="hidden" name="change" value="" />
</form>
</body>
</html>
]])
