<?php
include_once 'classes/TestProjektSmarty.class.php';
require_once("config.inc.php");
$templatename = substr(basename($_SERVER['PHP_SELF']),0,-3)."html";
$smarty = new Smarty();
require_once "language/german.inc.php";

require_once "validation/func_validEmail.php";
require_once "func_genUser.php";
require_once("func_verlauf.php");
require_once("func_mail_einstell.php");
require_once("func_rechte_vergabe.php");
require_once("func_beteiligter_status.php");

$action = $_GET['action'];

  if(isset($_GET['id'])){
    $_SESSION["edit_id"] = $_GET['id'];
    $search_prefix = 'ausschuss_beteiligte_uberblick_';
    $search_len = strlen($search_prefix);
    foreach( $_SESSION as $key => $value){
      if ( substr( $key, 0, $search_len) == $search_prefix) {
        unset( $_SESSION[$key]);
      }
    }
  }



if($action == ''){
  
    
    $id = $_SESSION["edit_id"];
  
    $query1 = "SELECT bid, vorname, nachname, date_format(frist_datum, '%d.%m.%Y') frist_tag, date_format(stellung_dat, '%d.%m.%Y (%H:%i)') stellung_dat_form, stellung_dat
                 FROM imt_beteiligte a, imt_user b
                WHERE a.imtuid=b.imtuid
                  AND a.vid='$id'
                ORDER BY nachname ASC";
  
    $result1 = $db->query ($query1)
              or die ("Cannot execute query");
    
    $table_data1 = array();
    
    $beteiligter = new beteiligter();
      
    while ($row1 = $result1->fetch_array()){
    
      $status = $beteiligter -> beteiligter_status($row1[bid]);
      $status_klartext = $beteiligter -> beteiligter_status_klartext($row1[bid], $status);
      
      array_push($table_data1, array(  
       'bid' => $row1[bid],
       'vorname' => $row1[vorname],
       'nachname' => $row1[nachname],
       'status' => $status,
       'status_klartext' => $status_klartext,
       'frist' => $frist,
       'frist_tag' => $row1[frist_tag]
      )
      );
    }
    $smarty->assign('table_data1', $table_data1);
    
    

}

$smarty->assign('action', "$action");
$smarty->display("$template/$templatename");

?>