<?php
  
$webdoc["page_title"].=" - Make Test Run";

/** zadani, pro jakeho uzivatele je tento soubor k dispozici
 *  soubor je k dispozici take vsem uzivatelum, kteri maji vyssi person_role
 * DA - 1
 * DE - 2
 * TA - 3
 * TE - 4
 * TT - 5    
*/ 
$person_role = 4;
if (!auth($person_role)) 
{
  $webdoc["message"][]=database_get_message("no_permission");
  $template->template_assign("no_display",true);
  return;
}


/** ------------------------------------------------------
 *  ZACATEK vlastniho PHP kodu
    ------------------------------------------------------ */ 

$webdoc["test_id"]=$_REQUEST["test_id"];
$webdoc["main_table"]="test";

if (isset($_POST["button_make_test_run"]))
{
  $url="./?subpage1=test_run&subpage2=new&test_id=$webdoc[test_id]"; //nova url
  header("location: $url"); //presmerovani
}

if (isset($_REQUEST["test_id"])) //test existence test_id
{
  $result=database_query("SELECT * FROM test WHERE test_id LIKE '$webdoc[test_id]'");
  $list = database_fetch_array($result);
  $template->template_assign("list",$list);
  $result=database_query("SELECT * FROM requirement_has_test WHERE test_id LIKE '$webdoc[test_id]'");
  $list_requirement_id = database_fetch_result($result,$row);
  $template->template_assign("list_requirement_id",$list_requirement_id);
  
  $make=true;
  if ($list["approver_id"]==0)
  {
    $webdoc["message"][]=database_get_message("no_approve_test");
    $make=false;
  }
  if ($list["terminator_id"]<>0)
  {
    $webdoc["message"][]=database_get_message("terminated_test");
    $make=false;
  }
  $template->template_assign("make",$make);
}

/** ------------------------------------------------------
 *  KONEC vlastniho PHP kodu
    ------------------------------------------------------ */ 

?>
