{% extends 'layouts/layout.twig' %}
{% block title %}{{ __('User') }}{% endblock %}

{% block content %}
		
	<div class="formWrapper">

		<form id="userform" method="POST" action="{{ path_for('user.update') }}" enctype="multipart/form-data">
		
			<section id="user" class="settings">

				<header class="headline">
					<h1>{{ userdata.username }}</h1>
				</header>
				
				<fieldset class="auth">

					{% for field in userform %}

						{% if field.type == 'fieldset' %}
											
							<fieldset class="subfield">
								<legend>{{ field.legend }}</legend>
								{% for field in field.fields %}
									{% include '/partials/fields.twig' with { 'settings': usersettings, 'object' : 'users', 'itemName' : 'user', 'class' : 'large', 'errors': errors } %}
								{% endfor %}
							</fieldset>
						
							{% else %}
								
								{% include '/partials/fields.twig' with { 'settings': usersettings, 'object' : 'users', 'itemName' : 'user', 'class' : 'large', 'errors': errors } %}

							{% endif %}
								
						{% endfor %}

						{% if is_role('administrator') %}
							<fieldset>
								<div class="large">
									<legend>Raw Userdata (readonly for admins)</legend>
									<textarea readonly="readonly" rows="10">{{ userdata|json_encode(constant('JSON_PRETTY_PRINT')) }}</textarea>
								</div>
							</fieldset>
						{% endif %}

				</fieldset>

			</section>
			<input type="submit" value="{{ __('Update User') }}" />

			{{ csrf_field() | raw }}
			<div class="actionLink">
				<a href="#" id="openModal" class="openModal">{{ __('Delete User') }}</a>
			</div>
		</form>
	</div>
	
	<div id="modalWindow" class="modal">
		<div class="modalInner">
			<div id="closeModal" class="closeModal">X</div>
			<form id="userdeleteform" method="POST" action="{{ path_for('user.delete') }}">
				<h2>{{ __('Delete') }} {{ userdata.username }}</h2>
				<p>{{ __('Do you really want to delete the user') }} {{userdata.username}}? {{ __('Please confirm') }}.</p>
				<input type="hidden" name="username" value="{{userdata.username}}">
				<input type="submit" class="danger" value="Delete user">
				{{ csrf_field() | raw }}
			</form>
		</div>
	</div>
	
{% endblock %}
