<?php
/*
# Fuer debugging
error_reporting(E_ALL);
ini_set('display_errors', 1);
#echo __LINE__."<br>";
*/
include_once 'classes/TestProjektSmarty.class.php';
$smarty = new Smarty();
require_once("config.inc.php");
$template = "standard";
$templatename = substr(basename($_SERVER['PHP_SELF']), 0, -3) . "html";
require_once "language/german.inc.php";

#$db = dbconnect();



$result0 = $db->query("SELECT DISTINCT 1
			  FROM prog_admin_rolle a, prog_admin b, prog_admin_rechte c, prog_admin_rollen_user_zuord d, prog_admin_rollen_rechte_zuord e
			 WHERE a.rid = d.rid
			   AND b.VAID = d.VAID
			   AND a.rid = e.rid
			   AND c.admin_rolle = e.admin_rolle
			   AND b.user = '$user_admin'
			   AND c.bereich = 'j'
                     ");
$row0 = $result0->fetch_array();


$smarty->assign('j_bereich', "$row0[0]");



$result1 = $db->query("SELECT DISTINCT 1
			  FROM prog_admin_rolle a, prog_admin b, prog_admin_rechte c, prog_admin_rollen_user_zuord d, prog_admin_rollen_rechte_zuord e
			 WHERE a.rid = d.rid
			   AND b.VAID = d.VAID
			   AND a.rid = e.rid
			   AND c.admin_rolle = e.admin_rolle
			   AND b.user = '$user_admin'
			   AND c.bereich = 'a'
                     ");
$row1 = $result1->fetch_array();


$smarty->assign('a_bereich', "$row1[0]");

$result3 = $db->query("SELECT DISTINCT 1
			  FROM prog_admin_rolle a, prog_admin b, prog_admin_rechte c, prog_admin_rollen_user_zuord d, prog_admin_rollen_rechte_zuord e
			 WHERE a.rid = d.rid
			   AND b.VAID = d.VAID
			   AND a.rid = e.rid
			   AND c.admin_rolle = e.admin_rolle
			   AND b.user = '$user_admin'
			   AND c.bereich = 'e'
                     ");
$row3 = $result3->fetch_array();

$smarty->assign('e_bereich', "$row3[0]");

$result2 = $db->query("SELECT DISTINCT 1
			  FROM prog_admin_rolle a, prog_admin b, prog_admin_rechte c, prog_admin_rollen_user_zuord d, prog_admin_rollen_rechte_zuord e
			 WHERE a.rid = d.rid
			   AND b.VAID = d.VAID
			   AND a.rid = e.rid
			   AND c.admin_rolle = e.admin_rolle
			   AND b.user = '$user_admin'
			   AND c.bereich = 's'
                     ");
$row2 = $result2->fetch_array();

$smarty->assign('s_bereich', "$row2[0]");



$query = "SELECT DISTINCT Beschreibung, dateiname, target
            FROM prog_admin_rolle a, prog_admin b, prog_admin_rechte c, prog_admin_rollen_user_zuord d, prog_admin_rollen_rechte_zuord e
	   WHERE a.rid = d.rid
	     AND b.VAID = d.VAID
	     AND a.rid = e.rid
	     AND c.admin_rolle = e.admin_rolle
	     AND b.user = '$user_admin'
            AND c.bereich = 'o'
          ORDER BY sort_order ASC
         ";
$result = $db->query( $query);

while ($row = $result->fetch_array())
{
  $value[] = $row;
}
$smarty->assign('table_data', $value);




$query6 = "SELECT DISTINCT Beschreibung, dateiname, target
            FROM prog_admin_rolle a, prog_admin b, prog_admin_rechte c, prog_admin_rollen_user_zuord d, prog_admin_rollen_rechte_zuord e
	   WHERE a.rid = d.rid
	     AND b.VAID = d.VAID
	     AND a.rid = e.rid
	     AND c.admin_rolle = e.admin_rolle
	     AND b.user = '$user_admin'
             AND c.bereich = 'j'
           ORDER BY sort_order ASC
         ";
$result6 = $db->query( $query6);
while ($row6 = $result6->fetch_array())
{
  $value6[] = $row6;
}
$smarty->assign('table_data1', $value6);



$query7 = "SELECT DISTINCT Beschreibung, dateiname, target
            FROM prog_admin_rolle a, prog_admin b, prog_admin_rechte c, prog_admin_rollen_user_zuord d, prog_admin_rollen_rechte_zuord e
	   WHERE a.rid = d.rid
	     AND b.VAID = d.VAID
	     AND a.rid = e.rid
	     AND c.admin_rolle = e.admin_rolle
	     AND b.user = '$user_admin'
             AND c.bereich = 'b'
           ORDER BY sort_order ASC
         ";
$result7 = $db->query( $query7);
while ($row7 = $result7->fetch_array())
{
  $value7[] = $row7;
}
$smarty->assign('table_data2', $value7);


$query8 = "SELECT DISTINCT Beschreibung, dateiname, target
            FROM prog_admin_rolle a, prog_admin b, prog_admin_rechte c, prog_admin_rollen_user_zuord d, prog_admin_rollen_rechte_zuord e
	   WHERE a.rid = d.rid
	     AND b.VAID = d.VAID
	     AND a.rid = e.rid
	     AND c.admin_rolle = e.admin_rolle
	     AND b.user = '$user_admin'
             AND c.bereich = 'e'
           ORDER BY sort_order ASC
         ";
$result8 = $db->query( $query8);
while ($row8 = $result8->fetch_array())
{
  $value8[] = $row8;
}
$smarty->assign('table_data3', $value8);




$query8a = "SELECT DISTINCT Beschreibung, dateiname, target
            FROM prog_admin_rolle a, prog_admin b, prog_admin_rechte c, prog_admin_rollen_user_zuord d, prog_admin_rollen_rechte_zuord e
	   WHERE a.rid = d.rid
	     AND b.VAID = d.VAID
	     AND a.rid = e.rid
	     AND c.admin_rolle = e.admin_rolle
	     AND b.user = '$user_admin'
             AND c.bereich = 'c'
           ORDER BY sort_order ASC
         ";
$result8a = $db->query( $query8a);
while ($row8a = $result8a->fetch_array())
{
  $value8a[] = $row8a;
}
$smarty->assign('table_data3a', $value8a);



$query9 = "SELECT DISTINCT Beschreibung, dateiname, target
            FROM prog_admin_rolle a, prog_admin b, prog_admin_rechte c, prog_admin_rollen_user_zuord d, prog_admin_rollen_rechte_zuord e
	   WHERE a.rid = d.rid
	     AND b.VAID = d.VAID
	     AND a.rid = e.rid
	     AND c.admin_rolle = e.admin_rolle
	     AND b.user = '$user_admin'
             AND c.bereich = 'a'
           ORDER BY sort_order ASC   
         ";
$result9 = $db->query( $query9);
while ($row9 = $result9->fetch_array())
{
  $value9[] = $row9;
}
$smarty->assign('table_data4', $value9);


$query10 = "SELECT DISTINCT Beschreibung, dateiname, target
            FROM prog_admin_rolle a, prog_admin b, prog_admin_rechte c, prog_admin_rollen_user_zuord d, prog_admin_rollen_rechte_zuord e
	   WHERE a.rid = d.rid
	     AND b.VAID = d.VAID
	     AND a.rid = e.rid
	     AND c.admin_rolle = e.admin_rolle
	     AND b.user = '$user_admin'
             AND c.bereich = 's'
           ORDER BY sort_order ASC   
         ";
$result10 = $db->query( $query10);
while ($row10 = $result10->fetch_array())
{
  $value10[] = $row10;
}
$smarty->assign('table_data5', $value10);



$smarty->display("$template/$templatename");
?>