<%#
 Copyright 2008 Steven Barth <steven@midlink.org>
 Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
 Copyright 2011 Manuel Munz <freifunk at somakoma dot de>
 Licensed to the public under the Apache License 2.0.
-%>

<%+header%>

<% 
local uci = require "luci.model.uci".cursor()
local contact = uci:get_all("freifunk", "contact")
local nickname, name, mail, phone, location, note
local lon = uci:get_first("system", "system", "longitude")
local lat = uci:get_first("system", "system", "latitude")

if not contact then
	nickname, name, homepage, mail, phone, location, note = ""
else
	nickname = contact.nickname or ""
	name = contact.name or ""
	homepage = contact.homepage or {}
	mail = contact.mail or ""
	phone = contact.phone or ""
	location = uci:get_first("system", "system", "location") or contact.location
	note = contact.note or ""
end
%>

<h2 name="content"><%:Contact%></h2>

<fieldset xmlns="http://www.w3.org/1999/xhtml" class="cbi-section">
<legend><%:Operator%></legend>
	<div class="table" cellspacing="10" width="100%" style="text-align:left">
		<div class="tr"><div class="th" width="33%"><%:Nickname%>:</div><div class="td"><%=nickname%></div></div>
		<div class="tr"><div class="th" width="33%"><%:Realname%>:</div><div class="td"><%=name%></div></div>
		<div class="tr"><div class="th" width="33%"><%:Homepage%>:</div><div class="td">
			<% for k, v in ipairs(homepage) do %>
			<a href="<%=v%>"><%=v%></a><br />
			<% end %>
		</div></div>
		<div class="tr"><div class="th" width="33%"><%:E-Mail%>:</div><div class="td"><a href="mailto:<%=mail%>"><%=mail%></a></div></div>
		<div class="tr"><div class="th" width="33%"><%:Phone%>:</div><div class="td"><%=phone%></div></div>
	</div>
</fieldset>

<fieldset xmlns="http://www.w3.org/1999/xhtml" class="cbi-section">
<legend><%:Location%></legend>
	<div class="table" cellspacing="10" width="100%" style="text-align:left">
		<div class="tr"><div class="th" width="33%"><%:Location%>:</div><div class="td"><%=location%></div></div>
		<div class="tr"><div class="th" width="33%"><%:Coordinates%>:</div><div class="td"><%=lat%> <%=lon%> (<a href="<%=pcdata(luci.dispatcher.build_url("freifunk/map"))%>"><%:Show on map%>)</a></div></div>
	</div>
</fieldset>

<% if note then %>
<fieldset xmlns="http://www.w3.org/1999/xhtml" class="cbi-section">
<legend><%:Notice%></legend>
	<div class="table" cellspacing="10" width="100%" style="text-align:left">
		<div class="tr"><div class="td"><%=note%></div></div>
	</div>
</fieldset>
<%end%>

<%+footer%>
