<%@ page isELIgnored="false" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"      prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://struts.apache.org/tags-html"     prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-bean"     prefix="bean" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"       prefix="fmt" %>

<h2>Meine Daten</h2>

<div class="FORMULAR">

	<html:errors/>

	<html:form action="changeaccount" focus="vorname">
		<p><bean:message key="changeform.vorname"/>:
		<br><html:text property="vorname"/>

		<p><bean:message key="changeform.nachname"/>:
		<br><html:text property="nachname"/>

		<p><bean:message key="changeform.email"/>:
		<br><html:text property="email"/>
		
		<p><bean:message key="changeform.comment"/>:
		<br><html:textarea property="comment" cols="70" rows="5"/>

		<hr>
		
		<p><bean:message key="changeform.info"/>:

		<p><bean:message key="changeform.oldpassword"/>:
		<br><html:password property="altespasswort"/>
		<p><bean:message key="changeform.newpassword1"/>:
		<br><html:password property="neuespasswort1"/>
		<br><bean:message key="changeform.newpassword2"/>:
		<br><html:password property="neuespasswort2"/>
		
		<hr>

		<p><html:submit><bean:message key="changeform.submit"/></html:submit>
	</html:form>

	<p align="right">Ich m&ouml;chte mich vom System dauerhaft abmelden und meine Daten komplett <html:link action="accountdelete">l&ouml;schen</html:link>.</p>

</div>

<p>&nbsp;</p>

<c:if test="${sessionScope.User.ownRatingsCount > 0}">
	<hr>
	
	<h3>Von mir abgegebene Bewertungen</h3>

	<p>Durchschnitt: <fmt:formatNumber value="${sessionScope.User.averageOwnRatingsValue}" maxFractionDigits="2"/> (Bewertungen: ${sessionScope.User.ownRatingsCount}).</p>

	<table border="1" cellpadding="2" cellspacing="2">
		<tr>
			<th>&nbsp;</th> <th>Bewertung</th> <th>bewertetes Element</th> <th>Version der Bewertung</th> <th>Kommentar</th>
		</tr>

		<c:forEach items="${sessionScope.User.ownRatings}" var="rating" varStatus="nr">
			<tr>
				<td align="right"> ${nr.count} </td>
				<td align="right"> <fmt:formatNumber value="${rating.value}" maxFractionDigits="2"/> </td>
				<td>
					<c:choose>
						<c:when test="${empty rating.rateable}">
						</c:when>
						<c:when test="${rating.rateable.class.name == 'de.uka.ipd.consensus.impl.TopicImpl'}">
							Topic "<html:link action="topicview?id=${rating.rateable.id}">${rating.rateable.name}</html:link>"
						</c:when>
						<c:when test="${rating.rateable.class.name == 'de.uka.ipd.consensus.impl.AssociationImpl'}">
							Assoziation "<html:link action="associationview?id=${rating.rateable.id}">${rating.rateable.name}</html:link>"
						</c:when>
						<c:when test="${rating.rateable.class.name == 'de.uka.ipd.consensus.impl.AttributeImpl'}">
							Attribut "<html:link action="attributeview?id=${rating.rateable.attributeable.id}&amp;attrid=${rating.rateable.id}">${rating.rateable.name}</html:link>"
						</c:when>
						<c:when test="${rating.rateable.class.name == 'de.uka.ipd.consensus.impl.SynonymImpl'}">
							Synonym <html:link action="editsynonyms?id=${rating.rateable.topic.id}">"${rating.rateable.topic.name}" == "${rating.rateable.synonym.name}"</html:link>
						</c:when>
						<c:when test="${rating.rateable.class.name == 'de.uka.ipd.consensus.impl.TypeInstanceImpl'}">
							Typ <html:link action="edittypes?id=${rating.rateable.instance.id}">"${rating.rateable.type.name}" f&uuml;r Topic "${rating.rateable.instance.name}"</html:link>
						</c:when>
						<c:otherwise>
							${rating.rateable}
						</c:otherwise>
					</c:choose>
				</td>
				<td> ${rating.version} </td>
				<td> ${rating.comment} </td>
			</tr>
		</c:forEach>
		
	</table>
</c:if>

<c:if test="${sessionScope.User.ratingsCount > 0}">
	<hr>
	<p>Andere Benutzer bewerten mich durchschnittlich mit <fmt:formatNumber value="${sessionScope.User.averageRatingValue}" maxFractionDigits="2"/>
	   (Bewertungen: ${sessionScope.User.ratingsCount}).</p>
</c:if>
