<?php

class SYS_UTIL
{
  public function __construct()
  {
   
  }
  
 public function GetUserInfobox($uid,$mydb_handle)
 {
  $mydb_handle->query("SELECT userName, authText, a.authId FROM AdminUser as u LEFT JOIN AdminUserInformation as i ON u.userId = i.userId LEFT JOIN AdminAuthInformation as a ON u.authId = a.authId WHERE u.userId = $uid");
  $row = $mydb_handle->fetchRow();
 
  $UserName = $row['userName'];
  $AuthStatus = $row['authText'];
  
  $content="";
  
  $_SESSION['authId'] = $row['authId'];
  
  $content .= "<div class=\"user-section\"><div class=\"user-section-inner\">";
  $content .= "<img src=\"img/UserPic".$uid .".png\" alt=\"\">";
  $content .= "</div> <div class=\"user-info\">";
  $content .= "<div>" . $UserName . "</div>";
  $content .= "<div class=\"user-text-online\">" . $AuthStatus . "</div></div></div";
  
  return $content;
 }
 
 public function AccessAllowed($authid,$pageid,$mydb_handle)
 {
 
  $mydb_handle->query("SELECT * FROM AdminAuthAccess as a WHERE a.authId = $authid AND a.authStep=$pageid");
  $ResultCounter = $mydb_handle->count() ; 

  if ($ResultCounter > 0)
  {
    return true;
  }
  else
  {
    return false;
  }
  
 }
 
  
 public function GetMainMenue($authid,$pageId, $mydb_handle)
 {
  
  $content="";
  
  if ( $this->AccessAllowed($authid,1,$mydb_handle) )
  {
    if ($pageId == 1)
    {
        $content .=  "<li class=\"selected\">";
    }
    else
    {
       $content .=  "<li>";
    }
    $content .=  "<a href=\"index.php?pageId=1\">Info / Aufgaben</a></li>"; 
  }
  if ( $this->AccessAllowed($authid,2,$mydb_handle) )
  {
    if ($pageId == 2)
    {
        $content .=  "<li class=\"selected\">";
    }
    else
    {
       $content .=  "<li>";
    }
    $content .=  "<a href=\"index.php?pageId=2\">Status bestätiger Datensätze</a></li>"; 
  }
  if ( $this->AccessAllowed($authid,3,$mydb_handle) )
  {
    if ($pageId == 3)
    {
        $content .=  "<li class=\"selected\">";
    }
    else
    {
       $content .=  "<li>";
    }
    $content .=  "<a href=\"index.php?pageId=3\">Info / Aufgaben</a></li>"; 
  }
  if ( $this->AccessAllowed($authid,9,$mydb_handle) )
  {
     if ($pageId == 9)
    {
        $content .=  "<li class=\"selected\">";
    }
    else
    {
       $content .=  "<li>";
    }
    $content .=  "<a href=\"index.php?pageId=9\">Datensatz Verwaltung</a></li>"; 
  }
  if ( $this->AccessAllowed($authid,4,$mydb_handle))
  {
     if ($pageId == 4)
    {
        $content .=  "<li class=\"selected\">";
    }
    else
    {
       $content .=  "<li>";
    }
    $content .=  "<a href=\"index.php?pageId=4\">Zelteinteilung</a></li>"; 
  }
  if ( $this->AccessAllowed($authid,5,$mydb_handle) )
  {
     if ($pageId == 5)
    {
        $content .=  "<li class=\"selected\">";
    }
    else
    {
       $content .=  "<li>";
    }
    $content .=  "<a href=\"index.php?pageId=5\">Zeltübersicht</a></li>"; 
  }
  if ($this->AccessAllowed($authid,6,$mydb_handle))
  {
     if ($pageId == 6)
    {
        $content .=  "<li class=\"selected\">";
    }
    else
    {
       $content .=  "<li>";
    }
    $content .=  "<a href=\"index.php?pageId=6\">Jubiläumsverwaltung</a></li>"; 
  }
  if ($this->AccessAllowed($authid,7,$mydb_handle))
  {
     if ($pageId == 7)
    {
        $content .=  "<li class=\"selected\">";
    }
    else
    {
       $content .=  "<li>";
    }
    $content .=  "<a href=\"index.php?pageId=7\">Gästeverwaltung</a></li>"; 
  }
  if ($this->AccessAllowed($authid,10,$mydb_handle) )
  {
     if ($pageId == 10)
    {
        $content .=  "<li class=\"selected\">";
    }
    else
    {
       $content .=  "<li>";
    }
    $content .=  "<a href=\"index.php?pageId=10\">Führungszeugnisverwaltung</a></li>"; 
  }
  if ($this->AccessAllowed($authid,8,$mydb_handle))
  {
     if ($pageId == 8)
    {
        $content .=  "<li class=\"selected\">";
    }
    else
    {
       $content .=  "<li>";
    }
    $content .=  "<a href=\"index.php?pageId=8\">Listenübersicht</a></li>"; 
  }
   if ($this->AccessAllowed($authid,11,$mydb_handle))
  {
     if ($pageId == 11)
    {
        $content .=  "<li class=\"selected\">";
    }
    else
    {
       $content .=  "<li>";
    }
    $content .=  "<a href=\"index.php?pageId=11\">Buchungslauf</a></li>"; 
  }  
  
  return $content;
 }
  
 public function GetContent($siteId)
 {
   $content = "<div class=\"row\"> <div class=\"col-lg-12\">";

   switch($siteId)
   {
   case 0:
    {
      $content .= "<h1 class=\"page-header\">Keine Zugriffsberechtigung</h1>";
      break;
    }
   case 1:
    {
      $content .= "<h1 class=\"page-header\">Info / Aufgaben</h1>";
      break;
    }
   case 2:
    {
      $content .= "<h1 class=\"page-header\">Status der bestätigten Datensätze</h1>";
      break;
    }
   case 3:
    {
     $content .= "<h1 class=\"page-header\">Verwaltung der PDF-Dokumente</h1>";
     break;
    }
   case 4:
    {
      $content .= "<h1 class=\"page-header\">Zelteinteilung</h1>";
      break;
    }
   case 5:
    {
     $content .= "<h1 class=\"page-header\">Übersicht der Zelteinteilung</h1>";
     break;
    }
   case 6:
    {
      $content .= "<h1 class=\"page-header\">Jubiläumsverwaltung</h1>";
      break;
    }
   case 7:
    {
     $content .= "<h1 class=\"page-header\">Gästeverwaltung</h1>";
     break;
    }
   case 8:
    {
      $content .= "<h1 class=\"page-header\">Listenübersicht</h1>";
      break;
    }
    case 9:
    {
      $content .= "<h1 class=\"page-header\">Verwaltung Datensatz</h1>";
      break;
    }
    case 10:
    {
      $content .= "<h1 class=\"page-header\">Verwaltung Führungszeugnis</h1>";
      break;
    }
    case 11:
    {
      $content .= "<h1 class=\"page-header\">Verwaltung Buchungslauf</h1>";
      break;
    }
    case 999:
    {
      $content .= "<h1 class=\"page-header\">Profilverwaltung</h1>";
      break;
    }
   default:
    {
     $content .= "<h1 class=\"page-header\">Headline not defined !</h1>";
     break;
    }

   }
   
   ob_start();
   include("core/step" . $siteId . ".php");
   $variable=ob_get_contents();
   ob_end_clean();
   $content .=  $variable;
   
   $content .= "</div></div>";
    
   return $content;         
  }
  
}

?>
