<div id=main_nav_accordion>
<h3 class="nav_accordion">Server</h3>
<div class="nav_accordion">

[% IF user_info.admin %]

<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/global_conf.cgi">
[% INCLUDE print_hidden.tt %]
<input type=hidden name=action value=conf>
<input type=submit title="Server configuration" value="Server Configuration">
</form>
</div>

<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/global_conf.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit title="Manual configuration" value="Configure manually">
</form>
</div>


[% IF hostname == global_config.passwds.passwd_server || global_config.passwds.passwd_server == 'localhost' %]
<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/usermanage.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit title="User management" value="Manage users">
</form>
</div>


<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/task.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit title="Manage authorisations" value="Authorisations">
</form>
</div>
[% END %]

[% END %]

[% FOR i IN global_config.celltest.rigs.split('\s*\,\s*') %]
<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/rig_main.cgi">
<input type=hidden name=name value="[% user_info.name %]" >
<input type=hidden name=pass value="[% user_info.pass %]" >
<input type=hidden name=forceutf8 value="&#x2713;" >
<input type=hidden name=sudo value="[% user_info.sudo %]" >
<input type="hidden" name="rig" value="[% i %]">
<input type=submit value="Rig [% i %]">
</form>
</div>
[% END %]

</div>


<h3 class="nav_accordion">Utilities</h3>
<div class="nav_accordion">

[% IF hostname == global_config.passwds.passwd_server || global_config.passwds.passwd_server == 'localhost' %]
<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/changepwd.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit value="Change password">
</form>
</div>
[% END %]


<div class=sidebar_item>
<form target="_blank" method=post action="/cgi-bin/celltest/utilities.cgi">
[% INCLUDE print_hidden.tt %]
<input type="hidden" name="action" value="pO2">
<input type=submit title="pO2 monitor calibration (Opens in new tab)" value="pO2 calibration">
</form>
</div>

<div class=sidebar_item>
<form target="_blank" method=post action="/cgi-bin/celltest/utilities.cgi">
[% INCLUDE print_hidden.tt %]
<input type="hidden" name="action" value="ch4">
<input type=submit title="Calculate Emf with carbon containing gasses (Opens in new tab)" value="Carbon emf">
</form>
</div>

<div class=sidebar_item>
<form target="_blank" method=post action="/cgi-bin/celltest/utilities.cgi">
[% INCLUDE print_hidden.tt %]
<input type="hidden" name="action" value="imp_comp">
<input type=submit title="Impedance compensation (Opens in new tab)" value="Impedance">
</form>
</div>

<div class=sidebar_item>
<form target="_blank" method=post action="/cgi-bin/celltest/utilities.cgi">
[% INCLUDE print_hidden.tt %]
<input type="hidden" name="action" value="fu">
<input type=submit title="Fuel utilisation correction calcualtion (Opens in new tab)" value="Fuel utilisation">
</form>
</div>

[% IF user_info.allow_search_reports %]
<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/search_reports.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit title="Seach processed test reports" value="Reports">
</form>
</div>
[% END %]

</div>


[% IF rig_info.name %]

<h3 class="nav_accordion">Rig [% rig_info.name %]</h3>
<div class="nav_accordion">

<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/rig_main.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit title="Rig [% rig_info.name %] main control page" value="Main page">
</form>
</div>

[% IF RFCfurnace %]
<div class=sidebar_item>
<form method=post action="/cgi-bin/RFCfurnace/furnace.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit title="To furnace control main control page" value="Furnace [% rig_info.name %]">
</form>
</div>
[% END %]

[% IF user_info.auth %]
<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/iv_setup.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit title="Setup IV curve parameters for Rig [% rig_info.name %]" value="Setup iV">
</form>
</div>

<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/start_new_test.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit title="Start a new test on Rig [% rig_info.name %]" value="New test">
</form>
</div>

<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/setup_program.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit title="Setup and run sequential programs for Rig [% rig_info.name %]" value="Program">
</form>
</div>
[% END %]

[% IF user_info.allow %]
<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/logbook.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit title="Logbook for Rig [% rig_info.name %]" value="Logbook for rig">
</form>
</div>
[% END %]

<div class=sidebar_item>
<input type="button" value="Plot values" onclick="myRFC_open('plot_values.cgi',800,600,100,100,'plot')" title="Plot active data for Rig [% rig_info.name %]">
</div>

</div>

[% IF user_info.cert %]

<h3 class="nav_accordion">Configuration of Rig [% rig_info.name %]</h3>
<div class="nav_accordion">

<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/device_config.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit title="Device setup and configuration for rig [% rig_info.name %]" value="Device configuration">
</form>
</div>

<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/misc_conf_template.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit title="Miscelaneous setup for Rig [% rig_info.name %]" value="Misc. setup">
</form>
</div>

<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/crontab.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit title="Scheduler for Rig [% rig_info.name %]" value="Crontab setup">
</form>
</div>

<div class=sidebar_item>
<form method="post" action="manual_edit_prog.cgi" enctype="multipart/form-data">
[% INCLUDE print_hidden.tt %]
<input type="submit" name="" value="Flow variation macro" title="Setup flow variation macro program (refer manual)">
<input type="hidden" name="file" value="flowvar"></form>
</div>

<div class=sidebar_item>
<form method="post" action="manual_edit_prog.cgi" enctype="multipart/form-data">
[% INCLUDE print_hidden.tt %]
<input type="submit" name="" value="Impedance macro" title="Setup impedance macro program (refer manual)">
<input type="hidden" name="file" value="impedance"></form>
</div>

<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/edit_conf.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit title="Manual configuration of Rig [% nav.rig %]" value="Manual configuration">
</form>
</div>

<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/setup_gui.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit title="Rig [% rig_info.name %] UI setup" value="GUI setup">
</form>
</div>


<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/iv_setup.cgi">
[% INCLUDE print_hidden.tt %]
<input type=submit title="Set thermocouple callibration" value="Thermocouples">
<input type = hidden name = action value = "calibration">
</form>
</div>


</div>

[% END %]


[% IF user_info.auth %]

<h3 class="nav_accordion">Current test</h3>
<div class="nav_accordion">

<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/show_log.cgi">
[% INCLUDE print_hidden.tt %]
<input type=hidden name=log value="userlog">
<input type=submit title="Complete logbook for rig [% rig_info.name %]" value="Logbook for test">
</form>
</div>

<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/show_log.cgi">
[% INCLUDE print_hidden.tt %]
<input type=hidden name=log value="proglog">
<input type=submit title="Complete program log for rig [% rig_info.name %]" value="Program log">
</form>
</div>

<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/show_log.cgi">
[% INCLUDE print_hidden.tt %]
<input type=hidden name=log value="errorlog">
<input type=submit title="Complete error log for rig [% rig_info.name %]" value="Error log">
</form>
</div>

<div class=sidebar_item>
<form method=post action="/cgi-bin/celltest/show_log.cgi">
[% INCLUDE print_hidden.tt %]
<input type=hidden name=log value="info">
<input type=submit title="Test information for rig [% rig_info.name %]" value="Test information">
</form>
</div>

<!--
<div class=sidebar_item>
<input type="button" title="Jdata file (processed data)" value="Data" onclick="openInNewTab('https://[% hostname %]/cgi-bin/show_data.cgi?name=[% user_info.name %]&pass=[% user_info.pass %]&url=http://[% hostname %]/rig[% rig_info.name %]/[% rig_info.name %]test[% rig_info.current_test %]/jdata')">
</div>

<div class=sidebar_item>
<input type="button" value="Raw data" onclick="openInNewTab('https://[% hostname %]/cgi-bin/show_data.cgi?name=[% user_info.name %]&pass=[% user_info.pass %]&url=http://[% hostname %]/rig[% rig_info.name %]/[% rig_info.name %]test[% rig_info.current_test %]/raadata')">
</div>
-->

<div class=sidebar_item>
<input type="button" value="All data" onclick="openInNewTab('https://[% hostname %]/cgi-bin/show_data.cgi?name=[% user_info.name %]&pass=[% user_info.pass %]&url=http://[% hostname %]/rig[% rig_info.name %]/[% rig_info.name %]test[% rig_info.current_test %]/')">
</div>



</div>

[% END %]

[% END %]



</div>



<script>
     


\$(function() {
    var icons = {
    header: "ui-icon-triangle-1-e white",
    activeHeader: "ui-icon-triangle-1-s white"
    };

    var icons_blank = {
    header: "ui-icon-blank",
    activeHeader: "ui-icon-blank"
    };
   \$("#main_nav_accordion").accordion({
    heightStyle:"content", 
    icons:icons,
    collapsible:true,
    active:false,
    beforeActivate: function( event, ui ) 
    {return my_actions(\$(ui.newHeader)[0]);},
          create: function( event, ui ) {
                    \$( this ).find( ".ui-accordion-header" ).each( function( i, element ) {
            var iconClass = "";
            if ( \$( element ).hasClass("no_arrow" ) ) {
                iconClass = "ui-icon-blank";
            }
            \$( element ).find( "span" ).addClass( iconClass );
        });

    }
    


  });
});

function my_actions(ac)
{
        if (ac == null)
        {       
                return true;
        }       
	return true;
}


function myRFC_open(script,w,h,l,t,winref)
{
    var hidden = "?name=[% user_info.name %]&pass=[% user_info.pass %]&rig=[% rig_info.name %]";
        var myWindow=window.open(script+hidden,winref,'width='+w+',height='+h+',left='+l+',top='+t);
    myWindow.location.href = script+hidden;
    if (!myWindow.opener)
        myWindow.opener = self;
    myWindow.resizeTo(w,h);
    myWindow.focus();
}



</script>