[%# Edit incoming address field mapping for email_in.pl
  # License: Dual-license GPL 3.0+ or MPL 1.1+
  # Contributor(s): Vitaliy Filippov <vitalif@mail.ru>
  #%]

[% PROCESS global/header.html.tmpl
  title = "Edit incoming addresses of email_in.pl"
%]

[% SET field_descs.group_ids = "Group ID's to grant automatically" %]

<form method="post" action="?">
<input type="hidden" name="do" value="1" />
[% IF !mode_add %]
<table class="editemin">
    <tr><th>Field</th><th>Value</th><th></th></tr>
[% FOR f = fields %]
    [% IF la != f.address %]
    <tr><th colspan="3"><b>[% f.address | html %]</b> (<a href="?add=1&email=[% f.address FILTER html %]">add a field value for this address</a>)</th></tr>
    [% SET la = f.address %]
    [% END %]
    <tr>
        <td>[% field_descs.${f.field} | html %]: &nbsp;</td>
        <td><input style="width: 250px" type="text" name="f_[% f.address FILTER html %]_[% f.field FILTER html %]" value="[% f.value FILTER html %]" /></td>
        <td><input type="checkbox" name="del_[% f.address FILTER html %]_[% f.field FILTER html %]" value="1" id="del_[% f.address FILTER html %]_[% f.field FILTER html %]" /> <label for="del_[% f.address FILTER html %]_[% f.field FILTER html %]">delete</label></td>
    </tr>
[% END %]
</table>
<p><input type="submit" value="Save Changes" /> or <a href="?add=1">Add a new field value</a></p>
[% ELSE %]
<input type="hidden" name="add" value="1" />
<table>
<tr><td>E-mail address:</td><td><input style="width: 250px" type="text" name="email" value="[% email FILTER html %]" /></td></tr>
<tr><td>Field:</td><td><select name="field" style="width: 250px">
[% FOR f IN field_descs.keys.sort %]
<option value="[% f FILTER html %]"[% IF curfield == f %] selected="selected"[% END %]>[% field_descs.${f} FILTER html %]</option>
[% END %]
</select></td></tr>
<tr><td>Value:</td><td><input type="text" style="width: 250px" name="value" value="[% value FILTER html %]" /></td></tr>
</table>
<p><input type="submit" value="Add field" /></p>
[% END %]
</form>

[% PROCESS global/footer.html.tmpl %]
