{% include 'header.twig' %}

<div class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">

            <div class="well">
								  {% if error %}
									<div class="alert alert-dismissible alert-danger">
									  <button type="button" class="close" data-dismiss="alert">×</button>
									  {{ errorText }}
									</div>
								  {% endif %}
								  {% if success %}
									<div class="alert alert-dismissible alert-success">
									  <button type="button" class="close" data-dismiss="alert">×</button>
									  {{ successText }}
									</div>
								  {% endif %}
                <div class="form-group">
                    <label for="username" class="control-label">{{ lang['account.username'] }}</label>
                    <input class="form-control" type="text" value="{{user['username']}}" readonly>
                </div>

                <div class="form-group">
                    <label for="email" class="control-label">Email</label>
                    <input class="form-control" type="text" value="{{user['email']}}" readonly>
                </div>
            </div>

            <div class="well">
                <form method="post" action="account">
                    <div class="form-group">
                        <label for="current" class="control-label">{{ lang['account.password.current'] }}</label> 
                        <input type="password" class="form-control" name="current_password">
                    </div>
                    <div class="form-group">
                        <label for="new" class="control-label">{{ lang['account.password.new'] }}</label>
                        <input type="password" class="form-control" name="password">
                    </div>
                    <div class="form-group">
                        <label for="confirm" class="control-label">{{ lang['account.password.confirm'] }}</label>
                        <input type="password" class="form-control" name="confirm_password">
                    </div>
                    <button type="submit" class="btn btn-primary">Change password</button>
                </form>
            </div>


							{% if site['languages']|length > 1 %}
            <div class="well">
                <form method="post" action="account/change_lang">
                    <div class="form-group">
                        <label for="charge" class="control-label">{{ lang['account.changelang.title'] }}</label>
                        <select class="form-control" name="lang">
									  {% for language in site['languages'] %}
									  <option {% if language["code"] == user["lang"] %} selected {% endif %} value="{{ language["code"] }}">{{ language["name"] }}</option>
									  {% endfor %}
                        </select>
                    </div>
                    <button type="submit" class="btn btn-primary">{{ lang['account.changelang.button'] }}</button>
                </form>
            </div>
{% endif %}
            <div class="well">
<form method="post" action="account/timezone">
                    <div class="form-group">
                        <label for="language" class="control-label">{{ lang['account.timezone.title'] }}</label>
                        <select class="form-control" name="timezone">
										 {% for timezone in timezones %}
										 <option {% if timezone["timezone"] == user['timezone'] %} selected {% endif %} value="{{ timezone["timezone"] }}">{{ timezone["label"] }}</option>
										 {% endfor %}
                        </select>
                    </div>

                    <button type="submit" class="btn btn-primary">{{ lang['account.timezone.button'] }}</button>
                </form>
            </div>
            <div class="well">
                <form method="post" action="account/newapikey">
                    <div class="form-group">
                        <label for="language" style="color: #fff" class="control-label">API Key</label>
                        <input type="text" class="form-control" value="{{ user['apikey'] }}" readonly>
                    </div>
                        <input type="hidden" name="_csrf" value="{{csrftoken}}">
                    <button type="submit" class="btn btn-primary">{{ lang['account.generate.key'] }}</button>
                </form>
            </div>
        </div>
    </div>
</div>

{% include 'footer.twig' %}
