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

$home = "/usr/local/e-cron";
$server = param("server");
$change_status = param("change_status");
@project_jobnet_csv = param("project_jobnet");

print "Content-type: text/html\n\n";
###############contents insert#########
system("cat ../elements/header");
print "&nbsp;&nbsp;&nbsp;<a href=\"./server_info.cgi?${server}\">Back to Server Info</a>";

# change status
print "<br></br>";
print "<div style=\"padding-left:12px;\">";
print "<pre>";

unless(@project_jobnet_csv){
  print "No project and jobnet was cheked !";
}

if($change_status eq change_to_enable){

  foreach (@project_jobnet_csv) {
    @project_jobnet=split(/,/, $_);
    $project=@project_jobnet[0];
    $jobnet=@project_jobnet[1];
    system("sudo -u ejobmgr $home/bin/enable_jobnet $project/$jobnet $server");
  } 

}elsif($change_status eq change_to_disable){

  foreach (@project_jobnet_csv) {
    @project_jobnet=split(/,/, $_);
    $project=@project_jobnet[0];
    $jobnet=@project_jobnet[1];
    system("sudo -u ejobmgr $home/bin/disable_jobnet $project/$jobnet $server");
  } 

}elsif($change_status eq delete_jobnet) {
  foreach (@project_jobnet_csv) {
    @project_jobnet=split(/,/, $_);
    $project=@project_jobnet[0];
    $jobnet=@project_jobnet[1];
    system("sudo -u ejobmgr $home/bin/for_cgi/delete_jobnet $project/$jobnet $server");
  } 
}

print "</pre>";
print "</div>";
system("cat ../elements/footer");

