<?php

if ($webdoc["main_table"]=="requirement") $webdoc["page_title"].=" - Make Test";
else $webdoc["page_title"].=" - Make Test Run";

$person_role = 4;
if (!auth($person_role)) 
{
  $webdoc["message"][]=database_get_message("no_permission");
  $template->template_assign("no_display",true);
  return;
}

if (isset($_POST["button_make_test"]))
{
  
  if ($webdoc["main_table"]=="requirement") $url="./?subpage1=tests&subpage2=new&requirement_id=$_POST[requirement_id]"; //nova url
  else $url="./?subpage1=test_run&subpage2=new&product_id=$_POST[product_id]";
  header("location: $url"); //presmerovani
}

if (isset($webdoc["sequence_id"])) //test existence sequence_id
{
  if ($record=database_get_record()) //nacteni zaznamu do docasne prom.
  {
    $make=true;
    if ($record["approver_id"]==0)
    {
      if ($webdoc["main_table"]=="requirement") $webdoc["message"]["form_error"][]=database_get_message("no_approve_requirement");
      else $webdoc["message"]["form_error"][]=database_get_message("no_approve_test");
      $make=false;
    }
    if ($webdoc["main_table"]=="requirement")
    {
      if ($record["active"]==0)
      {
        $webdoc["message"]["form_error"][]=database_get_message("no_active_requirement");
        $make=false;
      }
    }
    $template->template_assign("make",$make);
    $template->template_assign("record",$record);
  }
  else
  {
    $webdoc["message"][]=database_get_message("record_not_found");
  }
}

?>
