<?php

$webdoc["page_title"].=" - Activation";

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

if (isset($webdoc["sequence_id"])) //test existence sequence_id
{
  if ($record=database_get_record()) //nacteni zaznamu do docasne prom.
  {
    if (isset($_POST["button_activate"]) && $record["active"]==0)
    {
      if (database_active_record($record["$webdoc[main_table]_id"],true))
      {
        $webdoc["message"][]=database_get_message("record_active");
        $record=database_get_record(); //znovunacteni pro vypsani aktualniho casu a uzivatele
      }
      else $webdoc["message"][]=database_get_message("error_activation");
    }
    elseif (isset($_POST["button_deactivate"]) && $record["active"]==1)
    {
      if (database_active_record($record["$webdoc[main_table]_id"]))
      {
        $webdoc["message"][]=database_get_message("record_not_active");
        $record=database_get_record(); //znovunacteni pro vypsani aktualniho casu a uzivatele
      }
      else $webdoc["message"][]=database_get_message("error_deactivation");
    }
    else
    {
      if ($record["active"]==1) $webdoc["message"][]=database_get_message("record_active");
      else $webdoc["message"][]=database_get_message("record_not_active");
    }
    $template->template_assign("record",$record);
  }
  else
  {
    $webdoc["message"][]=database_get_message("record_not_found");
  }
}
?>