<?php
  
$webdoc["page_title"].=" - History";

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

if (!isset($webdoc["sequence_id"])) return;

if (isset($_GET["test_id"])) $webdoc["test_id"]=(int)$_GET["test_id"];

kernel_get_url($filter,$columns,$pages,$sort);

$url=kernel_create_filter_url($filter).kernel_create_columns_url($columns); //url pro vypis stranek a prispevku na stranku. Parametry stranky budou nastaveny zvlast pro kazdy odkaz
$url_pages=kernel_create_pages_url($pages); //url pro ostatni odkazy (vcetne aktualni stranky)
$url_sort=kernel_create_sort_url($sort); //url pro razeni

$pages["url"]=$url.$url_sort;
$sort2["url"]=$url.$url_pages;

$url.=$url_pages.$url_sort;

//$list=database_get_history($rows); //vrati seznam pozadavku
$list=database_get_list($rows,$pages["records_total"],$pages,$sort,$columns); //vrati seznam pozadavku

kernel_create_pages($pages); //dopocitani dalsich promennych stranky pro sablonu
kernel_create_sort($sort,$sort2,$columns); //dopocitani dalsich promennych pro razeni zaznamu

if ($pages["records_total"]==0)
{
  $webdoc["message"][]=database_get_message("record_not_found");
  return;
}

switch ($webdoc["main_table"])
{
  case "requirement": $columns_array=array("name","description","comments","category","parent","created","creator","approved","approver","active","is_product_specific"); break;
  case "product": $columns_array=array("name","description","comments","category","parent","created","creator","approved","approver"); break;
  case "test": $columns_array=array("name","created","creator","approved","approver","acceptance_criteria","comments","terminate","terminator"); break;
 }

foreach ($columns as $name => $value) //nastaveni poli pro funkci view_result
{
  if (in_array($name,$columns_array)) switch ($name)
  {
    case "name": $title[]="Name"; $values[]=$name; break;
    case "description": $title[]="Description"; $values[]=$name; break;
    case "category": $title[]="Category"; $values[]=$name; break;
    case "parent": $title[]="Parent"; $values[]=$name; break;
    case "created": $title[]="Created"; $values[]=$name; break;
    case "creator": $title[]="Creator"; $values[]=$name; break;
    case "approved": $title[]="Approved"; $values[]=$name; break;
    case "approver": $title[]="Approver"; $values[]=$name; break;
    case "tested": $title[]="Tested"; $values[]=$name; break;
    case "tester": $title[]="Tester"; $values[]=$name; break;
    case "active": $title[]="Active"; $values[]=$name; break;
    case "is_product_specific": $title[]="Is product specific"; $values[]=$name; break;
    case "acceptance_criteria": $title[]="Acceptance criteria"; $values[]=$name; break;
    case "sw_rev": $title[]="SW Rev"; $values[]=$name; break;
    case "hw_rev": $title[]="HW Rev"; $values[]=$name; break;
    case "setup": $title[]="Setup"; $values[]=$name; break;
    case "result": $title[]="Result"; $values[]=$name; break;
    case "duration": $title[]="Duration"; $values[]=$name; break;
    case "comments": $title[]="Comments"; $values[]=$name; break;
    case "terminate": $title[]="Terminated"; $values[]=$name; break;
    case "terminator": $title[]="Terminator"; $values[]=$name; break;
  }
}
if (isset($columns["actions"])) $title[]="Actions";


$template->template_assign("title",$title);
$template->template_assign("values",$values);

if ($webdoc["main_table"]=="test")
{
  $template->template_assign("actions",array("View"=>"view","Edit"=>"edit"));
  $template->template_assign("role",array("5","4"));
  $template->template_assign("parametr", array("test_id","sequence_id"));
}
else 
{
  $template->template_assign("actions",array("View"=>"view","Edit"=>"edit","Copy"=>"copy"));
  $template->template_assign("role",array("5","1","5"));
  $template->template_assign("parametr", array("sequence_id","version"));
}

$template->template_assign("list",$list);

//$template->template_assign("url",$url); //url pro odkazy
$template->template_assign("columns_count",count($columns)); //pocet sloupcu 
$template->template_assign("pages",$pages); //nastaveni hodnot stranky ve formulari
$template->template_assign("sort",$sort); //nastaveni hodnot razeni ve formulari
$template->template_assign("sort2",$sort2); //nastaveni hodnot razeni ve formulari
$template->template_assign("columns",$columns); //nastaveni hodnot sloupcu ve formulari


  
?>
