<?php
ini_set("display_errors",true);
error_reporting(E_ALL);
session_start();
if(isset($_GET['logoff']) and $_GET['logoff'] == 1 ) { session_destroy(); session_start();}
$_SESSION['debug'] = false;
  include("init.php");
  // require_once("eaclass.php");
?>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>SNKO-Logbuch</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <?php
    echo "
    <style media=\"screen\">
    body {
      background-color: #acacac;
      /* color: #000; */
    }

    a {
      color: #000000;
    }
    a:active, a:visited {
      color: #000000;
      font-weight: bold;
      text-decoration: none;
    }
    a:hover {
      color: #555555;
      text-decoration: underline;
    }
    #del_entry {
      background-color: #ff0000;
      margin-left: 220px;
    }
    .container {
      width: 100%;
      /* border: 1px solid #000000; */
     display: grid;
     ";
      if($_SESSION['dauereinaus'] == "1" ){

        echo "grid-template-columns: 90px 1fr 50px 1fr;";
      } else {
        echo "grid-template-columns: 90px 1fr 1fr;";
      }
    echo "
    }
    .liste {
      border-bottom: 1px dotted #000000;
    }
    ";
    ?>
    </style>
    <!-- <link  href="LB_style.css" type="text/css" rel="stylesheet"> -->
  </head>
  <body>
    <?php
    if(isset($_SESSION['user_logged_in']) && $_SESSION['user_logged_in'] == "menu"){
    echo "<h2>SNKO-Logbuch</h2>";
    if(isset($_SESSION['readonly']) && $_SESSION['readonly'] == "1") { echo "Read Only Modus<br /><br />";}

   ?>
    <div id="menu">
      <?php
            echo $_SESSION['user'];
            if(isset($_SESSION['readonly']) && $_SESSION['readonly'] == "") {
              echo ' | <a href="index.php?cont=eingabe">Neu</a>';
            }
            echo ' | <a href="index.php?cont=liste">Liste</a> | ';
            if(isset($_SESSION['readonly']) && $_SESSION['readonly'] == "") {
              echo '<a href="index.php?cont=konfig">Konfig</a> | ';
            }
            echo '<a href="index.php?logoff=1">Exit</a>';
            ?>
          <!-- <a href="index.php?cont=config">Konfig</a> | -->
          <!-- <a href="index.php?cont=admin_update">Update</a> | <br/> -->
    </div>
    <!-- <a href="index.php?cont="></a> | <br/> -->
    <br />
    <br />
    <div id="inhalt">
    <?php
    if(isset($_SESSION['prefix'][3])) $cont = $_SESSION['prefix'][3];
    if(isset($_GET['cont'])) $cont = $_GET['cont'];
    if(isset($cont)) {
      switch ($cont) {
        case 'eingabe':
          $LB->eingabe();
          break;
        case "konfig":
          $LB->konfig();
          break;
        case 'liste':
          $LB->liste($_GET,$_POST);
          break;
        case 'aendern':
          $LB->aendern($_GET);
          break;
        case 'schreiben':
          $LB->schreiben($_POST);
          break;
        case 'updaten':
          $LB->updaten($_POST);
          break;
        // case "admin_update":
    		// 	if (isset($_GET['version'])) {$v = $_GET['version']; } else { $v = "";}
    		// 	$ADMIN->update($v);
  			//   break;
        // case "bereich":
    		// 	$ADMIN->admin_bereich_form($konfig['tbl_config'],$spalten['config']);
    		// 	break;
        //

        default:
          # code...
          break;
      }

    }
    // echo "<hr />\n";
    ?>
  </div>
  <?php
  }
  if (!isset($_SESSION['user_logged_in']) || $_SESSION['user_logged_in'] == false) {
    $USER->user_login();
  }

  ?>
  </body>
</html>
<?php
// $EA->liste();
 ?>
