<?php
global $webdoc;
$webdoc["page_title"].=" - Approve Test";

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

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

if (isset($_POST["button_approve"]))
{
  if (!database_approve_record($webdoc["test_id"])) $webdoc["message"][]=database_get_message("record_approved");     
}

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);
  
  if ($list["approved"]==0) $webdoc["message"][]=database_get_message("record_not_approved");
  else $webdoc["message"][]=database_get_message("record_approved");
}

?>