<?php 
/*
======================
Administraatori paneel
Kasutaja detailne vaade
======================
*/
include "config.php";
include ADMIN_ROOT . "header.php";
?>
<h2 class="decorated"><span>Kasutaja andmed</span></h2>
<?php

include_once ROOT . 'db/dbconfig.php';
include_once ADMIN_ROOT . 'objects/kasutaja.class.php';

$database = new Database();
$db = $database->dbConnection();

$kasutaja = new Kasutaja($db);
$kasutaja->id = $_GET['id'];
$stmt = $kasutaja->loeAndmed();
$num = $stmt->rowCount();

if($num>0){
    // Kuvame tabelisse kõik kasutaja informatsiooni
  echo "<br/><br/><table class='table table-hover table-responsive table-bordered'>";

  while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){

    extract($row);

    echo "<tr>";
    echo "<td width='30%'><b>Eesnimi</b></td>";
    echo "<td>{$eesnimi}</td>";
    echo "</tr><tr>";
    echo "<td><b>Perekonnanimi</b></td>";
    echo "<td>{$perekonnanimi}</td>";
    echo "</tr><tr>";
    echo "<td><b>Isikukood</b></td>";
    echo "<td>{$isikukood}</td>";
    echo "</tr><tr>";
    echo "<td><b>Telefon</b></td>";
    echo "<td>{$telefon}</td>";
    echo "</tr><tr>";
    echo "<td><b>E-mail</b></td>";
    echo "<td>{$email}</td>";
    echo "</tr><tr>";
    echo "<td><b>Aadress</b></td>";
    echo "<td>{$aadress}<br/>{$postiindeks}, {$linn}<br/>{$maakond}, {$riik}</td>";
    echo "</tr><tr>";
    echo "<td><b>Staatus</b></td>";
    echo "<td>";
    if ($staatus == "Y"){
      echo "Aktiveeritud";
  } else {
      echo "Ootab aktiveerimist";
  }
  echo "</td>";
}
echo "</table>";
}
else{
  echo "<br /><center>Kasutajat ei leitud.</center>";
}
echo '<button class="btn btn-large" onclick="goBack()"><span class="glyphicon glyphicon-chevron-left"></span>&nbsp;Tagasi</button>';
?>
<script>
    function goBack() {
        window.history.back();
    }
    </script
    <?php
    include ADMIN_ROOT . "footer.php";
    ?>