[% META title = 'device' %]

<script type="text/javascript" language="javascript">
<!--
	var htmlprops = new Array("titletext", "subtext");
	var visibleprops = new Array("fxs1fieldset", "fxs2fieldset", "fullnum1fieldset", "fullnum2fieldset");
	var valueprops = new Array("fieldset");

	var types = new Object();

	types["SPA9000"] = new Object();
	types["SPA9000"]["titletext"] = "Bitte tragen Sie die Mac-Adresse Ihrer Telefonanlage ein und weisen Sie bei Bedarf den analogen Anschlüssen eine Durchwahl zu";
	types["SPA9000"]["subtext"] = "Die Mac-Adresse ist eine Nummer und befindet sich auf der Unterseite Ihres Geräts.";
	types["SPA9000"]["fxs1fieldset"] = 1;
	types["SPA9000"]["fxs2fieldset"] = 1;
	types["SPA9000"]["fullnum1fieldset"] = 0;
	types["SPA9000"]["fullnum2fieldset"] = 0;
	types["SPA9000"]["fieldset"] = "small";

	types["PAP2T-EU"] = new Object();
	types["PAP2T-EU"]["titletext"] = "Bitte tragen Sie die Mac-Adresse Ihrer PAP ein und weisen Sie bei Bedarf den analogen Anschlüssen eine Durchwahl zu";
	types["PAP2T-EU"]["subtext"] = "Die Mac-Adresse ist eine Nummer und befindet sich auf der Unterseite Ihres Geräts.";
	types["PAP2T-EU"]["fxs1fieldset"] = 0;
	types["PAP2T-EU"]["fxs2fieldset"] = 0;
	types["PAP2T-EU"]["fullnum1fieldset"] = 1;
	types["PAP2T-EU"]["fullnum2fieldset"] = 1;
	types["PAP2T-EU"]["fieldset"] = "full";

	types["SPA9xx"] = new Object();
	types["SPA9xx"]["titletext"] = "Bitte tragen Sie die Mac-Adresse Ihres SPA9xx-Telefons ein.";
	types["SPA9xx"]["subtext"] = "Die Mac-Adresse ist eine Nummer und befindet sich auf der Unterseite Ihres Geräts.";
	types["SPA9xx"]["fxs1fieldset"] = 0;
	types["SPA9xx"]["fxs2fieldset"] = 0;
	types["SPA9xx"]["fullnum1fieldset"] = 0;
	types["SPA9xx"]["fullnum2fieldset"] = 0;
	types["SPA9xx"]["fieldset"] = "head";

	function ftyp_change() {
		var sel = document.forms["mainform"].elements["ftyp"].value;
		var type = types[sel];

		var i;
		for (i = 0; i < valueprops.length; i++) {
			var prop = valueprops[i];
			var ele = document.getElementById(prop);
			ele.value = type[prop];
		}
		for (i = 0; i < htmlprops.length; i++) {
			var prop = htmlprops[i];
			var ele = document.getElementById(prop);
			ele.innerHTML = type[prop];
		}
		for (i = 0; i < visibleprops.length; i++) {
			var prop = visibleprops[i];
			var ele = document.getElementById(prop);
			ele.style.visibility = type[prop] ? "visible" : "hidden";
			ele.style.display = type[prop] ? "block" : "none";
		}
	}
// -->
</script>

  <div id="headimg">
    <img src="/grafik/area.jpg" width="869" height="69" alt="" />
  </div>
  <div id="headtxt">Konfigurieren Sie Ihre Endgeräte.</div>
  
  <div id="main">
      
    <div id="topmsg">
        <p> [% messages.topmsg %] </p>
    </div>
    <div id="toperr">
        <p> [% messages.toperr %] </p>
        <p> [% messages.prov_error %] </p>
    </div>
 
    <div class="sperrehead"> 
        <h3>Gerätezuordnung</h3>
        <h2 class="umleitungfuer">Einstellungen für [% active_number %]</h2>
    </div>

    <div id="spalten31">
        
    <div class="spalte1">

        <div class="spalte1 content">
            
            <form class="anmelden feinstellungen">
			    <ul class="menueinstellungen">
                    <li><a href="/autosubscriber">Benutzer</a></li>
                    <li class="on"><a href="/autodevice">Endgeräte</a></li>
                </ul>
                <fieldset class="adminlistehead">
                    <p>
                        Hier können Sie Ihren Nebenstellen ein Endgerät zuordnen.
                    </p>
                </fieldset>
            </form>

            <h2>Endgerät einrichten</h2>

                
            <div class="einrichtunghw">
                <img src="/grafik/spa9000.jpg" width="260" height="224" alt="" class="imgleft" />
                <div class="right">
                    <h4 id="titletext"><!-- will be overwritten -->Bitte tragen Sie die Mac-Adresse Ihrer Telefonanlage ein und weisen Sie bei Bedarf den analogen Anschlüssen eine Durchwahl zu</h4>
                    <p id="subtext"><!-- will be overwritten -->Die Mac-Adresse ist eine Nummer und befindet sich auf der Unterseite Ihres Geräts.</p>
                    <form method="post" action="/autodevice/savespa" id="mainform">
                        <fieldset>
                            <label for="ftyp">Modell</label>
                            <select id="ftyp" name="fmodel" class="input20" onchange="ftyp_change(); return true;">
                                <option value="SPA9000"[% " selected" IF unit.model == "SPA9000" %]>Linksys SPA9000</option>
                                <option value="PAP2T-EU"[% " selected" IF unit.model == "PAP2T-EU" %]>Linksys PAP2</option>
                                <option value="SPA9xx"[% " selected" IF unit.model == "SPA9xx" %]>Linksys SPA9xx</option>
                            </select>
                            <br />
                        </fieldset>

                        <fieldset>
                            <label for="fmac">Mac-Adresse</label>
                            <input type="text" size="20" class="input20" id="fmac" name="mac" value="[% unit.mac %]"/>
                            <br />
                        </fieldset>
                        
                        <fieldset>
                            <label for="fip">IP-Adresse</label>
                            <input type="text" size="20" class="input20" id="fip" name="ip" value="[% unit.ip %]"/>
                            <br />
                        </fieldset>

			<input type="hidden" name="fieldset" id="fieldset" value="" />

                        <fieldset id="fxs1fieldset">
                            <label for="fxs1">DW Port 1</label>
                            <select id="fxs1" name="fxs1" class="input20">
                                <option selected="selected" value="0"></option>
                                [% FOREACH subscriber IN subscribers %]
                                    [% FOREACH extension = subscriber.extensions %]
                                        [% IF !extension.unit %]
                                            <option value="[% extension.subscriber_id %]">[% extension.preferences.extension %][% " (" _ extension.autoconf_displayname _ ")" IF extension.autoconf_displayname %]</option>
                                        [% ELSIF unit.fxs1_subscriber_id == extension.subscriber_id %]
                                            <option value="[% extension.subscriber_id %]" selected>[% extension.preferences.extension %][% " (" _ extension.autoconf_displayname _ ")" IF extension.autoconf_displayname %]</option>
                                        [% ELSIF unit.fxs2_subscriber_id == extension.subscriber_id %]
                                            <option value="[% extension.subscriber_id %]">[% extension.preferences.extension %][% " (" _ extension.autoconf_displayname _ ")" IF extension.autoconf_displayname %]</option>
                                        [% END %]
                                    [% END %]
                                [% END %]
                            </select>
                            <br />
                        </fieldset>
                        
                        <fieldset id="fxs2fieldset">
                            <label for="fxs2">DW Port 2</label>
                            <select id="fxs2" name="fxs2" class="input20">
                                <option selected="selected" value="0"></option>
                                [% FOREACH subscriber IN subscribers %]
                                    [% FOREACH extension = subscriber.extensions %]
                                        [% IF !extension.unit %]
                                            <option value="[% extension.subscriber_id %]">[% extension.preferences.extension %][% " (" _ extension.autoconf_displayname _ ")" IF extension.autoconf_displayname %]</option>
                                        [% ELSIF unit.fxs2_subscriber_id == extension.subscriber_id %]
                                            <option value="[% extension.subscriber_id %]" selected>[% extension.preferences.extension %][% " (" _ extension.autoconf_displayname _ ")" IF extension.autoconf_displayname %]</option>
                                        [% ELSIF unit.fxs1_subscriber_id == extension.subscriber_id %]
                                            <option value="[% extension.subscriber_id %]">[% extension.preferences.extension %][% " (" _ extension.autoconf_displayname _ ")" IF extension.autoconf_displayname %]</option>
                                        [% END %]
                                    [% END %]
                                [% END %]
                            </select>
                            <br />
                        </fieldset>

                        <fieldset id="fullnum1fieldset">
                            <label for="fullnum1">Nummer Port 1</label>
                            <select id="fullnum1" name="fullnum1" class="input20">
                                <option selected="selected" value="0"></option>
                                [% FOREACH subscriber IN subscribers %]
                                            <option value="[% subscriber.subscriber_id %]">Kopfnummer ([% "0" _ subscriber.ac _ " " _ subscriber.sn %])[% " (" _ subscriber.autoconf_displayname _ ")" IF subscriber.autoconf_displayname %]</option>
                                    [% FOREACH extension = subscriber.extensions %]
                                        [% IF !extension.unit %]
                                            <option value="[% extension.subscriber_id %]">DW [% extension.preferences.extension %][% " (" _ extension.autoconf_displayname _ ")" IF extension.autoconf_displayname %]</option>
                                        [% ELSIF unit.fxs1_subscriber_id == extension.subscriber_id %]
                                            <option value="[% extension.subscriber_id %]" selected>DW [% extension.preferences.extension %][% " (" _ extension.autoconf_displayname _ ")" IF extension.autoconf_displayname %]</option>
                                        [% ELSIF unit.fxs2_subscriber_id == extension.subscriber_id %]
                                            <option value="[% extension.subscriber_id %]">DW [% extension.preferences.extension %][% " (" _ extension.autoconf_displayname _ ")" IF extension.autoconf_displayname %]</option>
                                        [% END %]
                                    [% END %]
                                [% END %]
                            </select>
                            <br />
                        </fieldset>
 
                        <fieldset id="fullnum2fieldset">
                            <label for="fullnum2">Nummer Port 2</label>
                            <select id="fullnum2" name="fullnum2" class="input20">
                                <option selected="selected" value="0"></option>
                                [% FOREACH subscriber IN subscribers %]
                                            <option value="[% subscriber.subscriber_id %]">Kopfnummer ([% "0" _ subscriber.ac _ " " _ subscriber.sn %])[% " (" _ subscriber.autoconf_displayname _ ")" IF subscriber.autoconf_displayname %]</option>
                                    [% FOREACH extension = subscriber.extensions %]
                                        [% IF !extension.unit %]
                                            <option value="[% extension.subscriber_id %]">DW [% extension.preferences.extension %][% " (" _ extension.autoconf_displayname _ ")" IF extension.autoconf_displayname %]</option>
                                        [% ELSIF unit.fxs2_subscriber_id == extension.subscriber_id %]
                                            <option value="[% extension.subscriber_id %]" selected>DW [% extension.preferences.extension %][% " (" _ extension.autoconf_displayname _ ")" IF extension.autoconf_displayname %]</option>
                                        [% ELSIF unit.fxs1_subscriber_id == extension.subscriber_id %]
                                            <option value="[% extension.subscriber_id %]">DW [% extension.preferences.extension %][% " (" _ extension.autoconf_displayname _ ")" IF extension.autoconf_displayname %]</option>
                                        [% END %]
                                    [% END %]
                                [% END %]
                            </select>
                            <br />
                        </fieldset>
 
                        <div class="aconflinkbold">
                            <label for="fsave">Konfiguration speichern</label>
                            <input type="image" class="hidden" src="/grafik/dot_trans.gif" alt="" id="fsave" name="fsave" />
                        </div>

                    </form>

                    <br clear="all" />
                </div>

            </div>
        </div>

    </div>

    <div class="spalte2">
        <table class="devlist">
        [% IF unit.model %]
            <tr class="active">
                <td class="adminimg">
                    <img class="okprodimg" src="/grafik/ok_system.gif" width="22" height="22" alt="25" />
                </td>
                <td>
                    [% unit.mac %]
                </td>
                <td>
                    <form method="post" action="/autodevice/deldev">
                        <input type="hidden" name="duser" value="[% unit.username %]"/>
                        <input type="image" src="/grafik/delete.gif" alt="Gerät löschen" class="noborder" id="delphone[% unit.id %]" name="delphone" value="1"/>
                    </form>
                </td>
                <td>
                    <form method="post" action="/autodevice/index">
                        <input type="hidden" name="did" value="[% unit.id %]"/>
                        <input type="image" src="/grafik/edit.gif" alt="Gerät editieren" class="noborder" id="editdev[% unit.id %]" name="editdev" value="1"/>
                    </form>
                </td>
                <td>
                    <a href="http://[% unit.ip %]/admin/resync?[% unit.sync_url %]" target="_blank">
                        <img src="/grafik/schritte_ok.gif" width="22" alt="Synchronisieren" class="noborder"/>
                    </a>
                </td>
            </tr>
        [% END %]
        [% FOREACH phone IN phones %]
            <tr>
                <td class="adminimg">
                    <img class="okprodimg" src="/grafik/ok_phone.gif" width="22" height="22" alt="25" />
                </td>
                <td>
                    [% phone.mac %]
                </td>
                <td>
                    <form method="post" action="/autodevice/deldev">
                        <input type="hidden" name="duser" value="[% phone.username %]"/>
                        <input type="image" src="/grafik/delete.gif" alt="Gerät löschen" class="noborder" id="delphone[% phone.id %]" name="delphone" value="1"/>
                    </form>
                </td>
                <td>
                    <form method="post" action="/autodevice/savespa">
                        <input type="hidden" name="mac" value="[% unit.mac %]"/>
                        <input type="hidden" name="ip" value="[% unit.ip%]"/>
                        <input type="hidden" name="fxs1" value="[% unit.fxs1_subscriber_id %]"/>
                        <input type="hidden" name="fxs2" value="[% unit.fxs2_subscriber_id %]"/>
                        <input type="hidden" name="fmodel" value="[% unit.model %]"/>
                        <input type="hidden" name="editid" value="[% phone.id %]"/>
                        <input type="image" src="/grafik/edit.gif" alt="Gerät editieren" class="noborder" id="editphone[% phone.id %]" name="editphone" value="1"/>
                    </form>
                </td>
                <td>
                    <a href="http://[% phone.ip %]/admin/resync?[% phone.sync_url %]" target="_blank">
                        <img src="/grafik/schritte_ok.gif" width="22" alt="Synchronisieren" class="noborder"/>
                    </a>
                </td>
            </tr>
        [% END %]
        </table>
    </div>

</div>

</div>
<br clear="all" />

<script type="text/javascript" language="javascript">
<!--
	ftyp_change();
// -->
</script>
