#!/usr/bin/perl
use CGI qw(param);

$home="/usr/local/e-cron";
$server = $ENV{'QUERY_STRING'};
$server =~s/\s//g ;

@jobnet_list=`sudo -u ejobmgr $home/bin/for_cgi/distributed_jobnets $server`;

print "Content-type: text/html\n\n";
###############contents insert#########
system("cat ../elements/header");


print "<h3>${server}</h3>";
print "<h4>Jobnet List</h4>";
unless(@jobnet_list){
  print "<h6>No jobnet distributed yet</h6>";
  print "<h6>Please distribute jobnet from project menue</h6>";
  print "</div>";
  system("cat ../elements/footer");
  exit 1
}
print "<div class=\"large-6 columns\">";
print "<form method=\"post\" action=\"./delete_server.cgi\" class=\"custom\">";
print "<input type=\"hidden\" name=\"server\" value=\"$server\">";
print "<table>";
print "  <thead>";
print "    <tr>";
print "      <th>Project</th>";
print "      <th>Jobnet</th>";
print "      <th>Status</th>";
print "      <th>Exec Status</th>";
print "    </tr>";
print "  </thead>";
print "  <tbody>";

while (<@jobnet_list>){
 @jobnet_info=split(/,/, $_);
  print "    <tr>";
  print "       <td>$jobnet_info[0]</td>";
  print "       <td><a href=\"./set_jobnet_form.cgi?$jobnet_info[0],$jobnet_info[1]\">$jobnet_info[1]</a></td>";
  print "       <td>$jobnet_info[2]</td>";
  print "       <td><a href=\"./ls_log.cgi?$jobnet_info[0],$jobnet_info[1],$server\">$jobnet_info[3]</a></td>";
  print "    </tr>"; 
}

print "  </tbody>";
print "</table>";
print "<br>";
print "<input type=\"submit\" class=\"button\" value=\"Delete This Server Entry\">";
print "</form>";
print "</div>";
print "<div class=\"large-6 columns\">";
print "<a href=\"./server_info.cgi?${server}\">Back to Server Info</a></p>";
print "</div>";
system("cat ../elements/footer");
