<!-- Tempalte for Misc. conf -->
<br>
[% UNLESS user_info.cert %]
<h1>You are not authorised to change configuration for Rig [% rig_info.name %]</h1>
[% RETURN %]
[% END %]

<h1>Miscellaneous configuration for Rig [% rig_info.name %]</h1>

<div class="content-container fit-content">
<table class=misc_conf>
<tr><th colspan=2>Main setup</th></tr>
<tr><td>Cell area</td><td><input type="text" name="cell_area" onchange="change_val(this,'main')" id="cell_area" class="textfield" value="[% data.cell_area %]" autocomplete=off></td></tr>
<tr><td>Log all</td><td>
<select name="logall" onchange="change_val(this,'main')" id="logall" class="textfield" autocomplete=off>
[% IF data.logall.lower == 'yes' -%]
<option value="No">No</option>
<option value="Yes" selected=selected>Yes</option>
[% ELSE -%]
<option value="No" selected=selected>No</option>
<option value="Yes">Yes</option>
[% END -%]
</select>
</td></tr>
<tr><td title="Set warning email address to current user when starting a new test">set warning email on start</td><td>
<select name="set_warning_email_on_start" onchange="change_val(this,'main')" id="set_warning_email_on_start" class="textfield" autocomplete=off>
[% IF data.set_warning_email_on_start.lower == 'yes' -%]
<option value="No">No</option>
<option value="Yes" selected=selected>Yes</option>
[% ELSE -%]
<option value="No" selected=selected>No</option>
<option value="Yes">Yes</option>
[% END -%]
</select>
</td></tr>

<tr><td>Warning mails</td><td><input type="text" name="warning_mails" onchange="change_val(this,'main')" id="warning_mails" class="textfield" value="[% data.warning_mails %]" autocomplete=off></td></tr>
<tr><td title="Username to use if the normal system user is not appropriate">Mail user</td><td><input type="text" name="mailuser" onchange="change_val(this,'main')" id="mailuser" class="textfield" value="[% data.mailuser %]" autocomplete=off></td></tr>
<tr><td>Equipment ID</td><td><input type="text" name="equipmentid" onchange="change_val(this,'main')" id="equipmentid" class="textfield" value="[% data.equipmentid %]" autocomplete=off></td></tr>

<tr><td>Authorisation ID</td><td><input type="text" name="authorisationid" onchange="change_val(this,'main')" id="authorisationid" class="textfield" value="[% data.authorisationid %]" autocomplete=off></td></tr>
<tr><td>Authorisation</td><td>
<select name="authorisation" onchange="change_val(this,'main')" id="authorisation" class="textfield" autocomplete=off>
[% IF data.authorisation.lower == 'remote' -%]
<option value="local">Local</option>
<option value="remote" selected=selected>Remote</option>
[% ELSE -%]
<option value="local" selected=selected>Local</option>
<option value="remote">Remote</option>
[% END -%]
</select>
</td></tr>
<tr><td>Status</td><td>
<select name="status" onchange="change_val(this,'main')" id="status" class="textfield" autocomplete=off>
[% IF data.status.lower == 'disabled' -%]
<option value="Ok">OK</option>
<option value="Disabled" selected=selected>Disabled</option>
[% ELSE -%]
<option value="Ok" selected=selected>Ok</option>
<option value="Disabled">Disabled</option>
[% END -%]
</select>
</td></tr>

<tr><th colspan=2>Control logic setup</th></tr>
<tr><td>Templog for temperature addjustment</td><td>
<select name="templog_for_temperature_addjust" onchange="change_val(this,'control_logic')" id="templog_for_temperature_addjust" class="textfield" autocomplete=off>
<option value=""></option>
[% FOR i IN data.templogs -%]
<option value="[% i %]" [% IF i == data.templog_for_temperature_addjust %]selected=selected[% END %]>[% i %]</option>
[% END -%]
</select>
<tr><th colspan=2>Datalog setup</th></tr>
<tr><td>Additional log program</td><td>
<select name="additional_log_program" onchange="change_val(this,'datalog')" id="additional_log_program" class="textfield" autocomplete=off>
<option value=""></option>
[% FOR i IN data.logprograms -%]
<option value="[% i %]" [% IF i == data.additional_log_program %]selected=selected[% END %]>[% i %]</option>
[% END -%]
</select>
</td></tr>
<tr><td>Log program arguments</td><td><input class=textfield type="text" name="log_program_arguments" onchange="change_val(this,'datalog')" id="log_program_arguments" value="[% data.log_program_arguments %]" autocomplete=off></td></tr>

<tr><th colspan=2>Report setup</th></tr>
<tr><td>Gas names ivtable</td><td><input type="text" name="gas_names_ivtable" onchange="change_val(this,'report')" id="gas_names_ivtable" class="textfield" value="[% data.gas_names_ivtable %]" autocomplete=off></td></tr>
<tr><td>Temperature names history</td><td><input type="text" name="temp_names_history" onchange="change_val(this,'report')" id="temp_names_history" class="textfield" value="[% data.temp_names_history %]" autocomplete=off></td></tr>
<tr><td>Humidifier names history</td><td><input type="text" name="water_names_history" onchange="change_val(this,'report')" id="water_names_history" class="textfield" value="[% data.water_names_history %]" autocomplete=off></td></tr>
<tr><td>Gas names history</td><td><input type="text" name="gas_names_history" onchange="change_val(this,'report')" id="gas_names_history" class="textfield" value="[% data.gas_names_history %]" autocomplete=off></td></tr>
<tr><td>Current names history</td><td><input type="text" name="current_names_history" onchange="change_val(this,'report')" id="current_names_history" class="textfield" value="[% data.current_names_history %]" autocomplete=off></td></tr>
<tr><td>Simplechannel names history</td><td><input type="text" name="simple_names_history" onchange="change_val(this,'report')" id="simple_names_history" class="textfield" value="[% data.simple_names_history %]" autocomplete=off></td></tr>
<tr><th colspan=2>User interface setup (deprecated)</th></tr>
<tr><td>Temperature</td><td><input type="text" name="temp" onchange="change_val(this,'userinterface')" id="temp" class="textfield" value="[% data.temp %]" autocomplete=off></td></tr>
<tr><td>Gas</td><td><input type="text" name="gas" onchange="change_val(this,'userinterface')" id="gas" class="textfield" value="[% data.gas %]" autocomplete=off></td></tr>
<tr><td>Voltage</td><td><input type="text" name="voltage" onchange="change_val(this,'userinterface')" id="voltage" class="textfield" value="[% data.voltage %]" autocomplete=off></td></tr>
<tr><td>Current</td><td><input type="text" name="current" onchange="change_val(this,'userinterface')" id="current" class="textfield" value="[% data.current %]" autocomplete=off></td></tr>
<tr><td>Alert</td><td><input type="text" name="alert" onchange="change_val(this,'userinterface')" id="alert" class="textfield" value="[% data.alert %]" autocomplete=off></td></tr>
<tr><td>pO2 voltage range</td><td><input type="text" name="pO2_voltagerange" onchange="change_val(this,'userinterface')" id="pO2_voltagerange" class="textfield" value="[% data.pO2_voltagerange %]" autocomplete=off></td></tr>
<tr><td colspan=2><button class=rfcbutton style="float:right;">Save</button></td></tr>
</table>

</div>

<style>

.textfield {
    width:100%;
}

.misc_conf {
    text-align:left;
}

.misc_conf th, .misc_conf td {
    padding:5px;
}

.misc_conf th {
    text-align:center;
}
</style>


<script>

function set_val(res)
{
    var arr = res.split("\n");
    if (arr[0] == "OK" || arr[0] == "WARN")
    {
        if (arr[0] == "WARN")
        {
            alert(arr[3]);
        }
        var obj = document.getElementById(arr[1]);
        obj.disabled = false;
        obj.value = arr[2];
    }
    else
    {
        alert(arr[0]);
    }
}

function change_val(element,section)
{
    var n = element.name;
    var val = element.value;
    element.disabled = true;
    run_ajax('change_config.cgi','&action=change_config_value&section='+section+'&key='+n+'&value='+val,set_val);
}

</script>
