#if($form_action=="new")
#set($isNewAction=true)
#set ($server_names = [])
#foreach ($c in $sorter.sort($computers.fetchAll(),"name"))
#set($dummy=$server_names.add($c.name))
#end
#else
#set($isNewAction=false)
#end
<div id="dialog-form-${form_action}" title="${form_title}">
	<p class="validateTips">All form fields are required.</p>
	<form id="form-${form_action}" method="post" accept-charset="iso-8859-2" action="$root/$module/${form_action}-action.vm">
	<fieldset>
		<input type="hidden" name="key" id="key"/>
		#inputbox("name","Name",$isNewAction)
		<br>
		#inputbox("ipAddress","IP-Adresse",true)
		#inputbox("macAddress","MAC-Adresse",true)
		<br>
		<label for="serverName">Server</label>
		#dropdown( "serverName", $server_names,"")
		<br>
		#inputbox("hardwareType","Hardware-Typ",true)
		#inputbox("manufacturer","Hersteller",true)
		<br>
		#inputbox("model","Modell",true)
		#inputbox("serial","Seriennummer",true)
		<br>
		#inputbox("location","Lokation",true)
		#inputbox("roomNumber","Raumnummer",true)
		<br>
		#inputbox("purchaseDate","Kaufdatum",true)
		#inputbox("warranty","Garantiedatum",true)
		<br>
		#inputbox("orderNumber","Bestellnummer",true)
		#inputbox("inventoryNumber","Inventarnummer",true)
	</fieldset>
	</form>
</div>
<script type="text/javascript">
#if($isNewAction)
function form_${form_action}_load(o) {
				$("input#name").val('');
				$("input#ipAddress").val('');
				$("input#macAddress").val('');
				$("select#serverName").val('');
				$("input#hardwareType").val('');
				$("input#manufacturer").val('');
				$("input#model").val('');
				$("input#serial").val('');
				$("input#location").val('');
				$("input#roomNumber").val('');
				$("input#purchaseDate").val('');
				$("input#warranty").val('');
				$("input#orderNumber").val('');
				$("input#inventoryNumber").val('');
}
#else
function form_${form_action}_load(o) {
				$("input#key").val(o.name);
				$("input#name").val(o.name);
				$("input#ipAddress").val(o.ipAddress);
				$("input#macAddress").val(o.macAddress);
				if(o.server!="") {
					$("select#serverName").val(o.server);
				}
				$("input#hardwareType").val(o.hardwareType);
				$("input#manufacturer").val(o.manufacturer);
				$("input#model").val(o.model);
				$("input#serial").val(o.serial);
				$("input#location").val(o.location);
				$("input#roomNumber").val(o.roomNumber);
				$("input#purchaseDate").val(o.purchaseDate);
				$("input#warranty").val(o.warranty);
				$("input#orderNumber").val(o.orderNumber);
				$("input#inventoryNumber").val(o.inventoryNumber);
}
#end

function form_${form_action}_validate() {
	var valid = true;
	var name = $("input#name").filter(":visible");
	var mac = $("input#macAddress").filter(":visible");

	valid = checkIdentifier(name) && valid;
	valid = (mac.val()=="" || checkMacAddress(mac)) && valid;
	return valid;
}
</script>
