<?php

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

$person_role = 2;
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 (!$record["approved"] && isset($_POST["button_approve"]))
    {
      if (database_approve_record($record["$webdoc[main_table]_id"]))
      {
        $webdoc["message"][]=database_get_message("record_approved");
        $record=database_get_record(); //znovunacteni pro vypsani aktualniho casu a uzivatele
      }
      else $webdoc["message"][]=database_get_message("error_approving");
    }
    else
    {
      if ($record["approved"]) $webdoc["message"][]=database_get_message("record_approved");
      else $webdoc["message"][]=database_get_message("record_not_approved");
    }
    $template->template_assign("record",$record);
  }
  else
  {
    $webdoc["message"][]=database_get_message("record_not_found");
  }
}
?>