<?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";


# Wenn Seite neu aufgerufen wird, dann alle Sessions, die mit "ausschuss_sitzung_" beginnen löschen
if($_GET['new'] == 1){;
  $search_prefix = 'ausschuss_sitzung_';
  $search_len = strlen($search_prefix);
  foreach( $_SESSION as $key => $value){
    if ( substr( $key, 0, $search_len) == $search_prefix) {
      unset( $_SESSION[$key]);
    }
  }
}


$action = $_GET['action'];
if(isset($_GET['id'])){
  $_SESSION["status_id"] = $_GET['id'];
}
$status = $_SESSION["status_id"];
if($action == ''){
 
    
    
  $query = "SELECT isid, date_format(datum, '%d.%m.%Y') datum_form, date_format(datum, '%H:%i') zeit_form, raum, beschreibung
              FROM imt_sitzungen
             WHERE date_format(datum, '%Y%m%d') >= date_format(DATE_SUB(now(),INTERVAL 7 DAY), '%Y%m%d')";
  $result = $db->query ($query)
            or die ("Cannot execute query");

  $outer_loop = array();
  while ($row1 = $result->fetch_array()){
    
    
  
    array_push($outer_loop, array(
     'isid' => $row1[isid],
     'datum_form' => $row1[datum_form],
     'zeit_form' => $row1[zeit_form],
     'raum' => $row1[raum],
     'beschreibung' => $row1[beschreibung]
    )
    );
  }

  $smarty->assign('outer_loop', $outer_loop);
  
}

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

?>