<%--
    Document   : index
    Created on : 29.3.2010, 18:14:44
    Author     : Pavel Jandera
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<c:if test="${RequestData.jmeno == null}">
    <c:redirect url="index.jsp" />
</c:if>

<sql:setDataSource
    var="dataSource"
    driver="com.mysql.jdbc.Driver"
    url="jdbc:mysql://localhost:3306/videokonference?useUnicode=true&characterEncoding=UTF-8"
  user="videokonf"
  password="Purk118*"
/>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Uživatelský profil</title>
        <link rel="stylesheet" type="text/css" href="style.css" />
    </head>

    <body>
        <div id="header"></div>
        <div id="content" style="min-width: 800px">
            <div id="menu">
            <a href="logout.jsp">Odhlásit</a>
            <a href="edit.jsp">Upravit osobní informace</a>&nbsp;&nbsp;&nbsp;
            <c:if test="${RequestData.admin == true}">
                <a href="admin.jsp">Administrace</a>&nbsp;&nbsp;&nbsp;
            </c:if>
            <sql:query var="skupiny" dataSource="${dataSource}">
                SELECT skupina FROM prirazeni
                WHERE uzivatel='${RequestData.login}' AND skupina=1
            </sql:query>
            <c:if test="${skupiny.rowCount == 0}">
                <a href="configApp.jsp">Videokonference</a>&nbsp;&nbsp;&nbsp;
            </c:if>
            </div>

            
            <h1>Uživatel: ${RequestData.jmeno} ${RequestData.prijmeni}</h1>
            <p>Váš e-mail: <b>${RequestData.mail}</b></p>
            <p>Vaše URI: <b>${RequestData.uri}</b></p>
            <p>Vaše telefonní číslo: <b>${RequestData.telefon}</b></p>
            <sql:query var="skupiny" dataSource="${dataSource}">
                SELECT skupiny.nazev FROM skupiny, prirazeni
                WHERE prirazeni.uzivatel='${RequestData.login}' AND skupiny.id=prirazeni.skupina
            </sql:query>
            <p>Jste zařazeni v těchto skupinách:<b>
            <c:forEach var="row" items="${skupiny.rows}">
                <c:choose>
                    <c:when test="${row.nazev == 'nezařazení'}">
                        <c:out value="${row.nazev} - " /><span style='color: red'>uživatelé v této skupině nemohou vytvářet videokonference.</span>
                    </c:when>
                    <c:otherwise>
                        <c:out value="${row.nazev}, " />
                    </c:otherwise>
                </c:choose>
            </c:forEach>
            </b>
            </p>
        </div>
    </body>
</html>
