{% extends "MuzichUserBundle::layout.html.twig" %}

{% block title %}{{ 'title.myaccount'|trans({}, 'userui') }}{% endblock %}
{% block mainbox_classes %}mainbox_padding{% endblock %}

{% block content %}

<div id="myaccount">
  
    <h1>{{ 'my_account.title'|trans({}, 'userui') }}</h1>

    <ul>
      <li>
        <b>{{ 'my_account.username'|trans({}, 'userui') }}</b>: {{ user.name }}
        {% if app.user.isUsernameUpdatable %}
          (<a class="username_update" href="{{ path('change_username') }}">{{ 'my_account.change_username'|trans({}, 'userui') }}</a>)
        {% endif %}
      </li>
      <li>
        <b>{{ 'my_account.email'|trans({}, 'userui') }}</b>: {{ user.email }}
        {% if not app.user.emailConfirmed %}
          (<a href="{{ path('send_email_confirm') }}">{{ 'my_account.send_email_confirm'|trans({}, 'userui') }}</a>)
        {% endif %}
      </li>
    </ul>

    <form id="address_update" action="{{ path('update_address', {"token":app.user.getPersonalHash}) }}" method="post">
      <p>
        {{ 'my_account.address.form.ilivenear'|trans({}, 'userui') }}
        <input type="text" name="town" class="intext" value="{{ app.user.town }}" />
        {{ 'my_account.address.form.in'|trans({}, 'userui') }}
        <input type="text" name="country" class="intext" value="{{ app.user.country }}" />
        <input type="submit" value="{{ 'my_account.address.form.submit'|trans({}, 'userui') }}" class="button address_submit" />
        <img class="loader" style="display: none;" src="{{ asset('/bundles/muzichcore/img/ajax-loader.gif') }}" alt="loading"/>
      </p>
    </form>
    
    <p class="help">
      {{ 'my_account.help_clicks'|trans({}, 'userui') }}
    </p>

    <h2 data-open="myaccount_favorites_tags">{{ 'my_account.favorite_tags'|trans({}, 'userui') }}</h2>
    
    <div id="myaccount_favorites_tags" class="myaccount_part"
      {% if not form_tags_favorites|form_has_errors %}
       style="display: none;"
      {% endif %}
    >
      {% include "MuzichCoreBundle:Tag:tagFavoritesForm.html.twig" with { 
        'form'             : form_tags_favorites,
        'redirect'         : 'account',
        'form_name'        : form_tags_favorites_name,
        'favorite_tags_id' : favorite_tags_id
      } %}
    </div>

    <h2 data-open="myaccount_favorites_password">{{ 'my_account.change_password'|trans({}, 'userui') }}</h2>

    <div id="myaccount_favorites_password" class="myaccount_part {% if app.request.get('open') == 'change_password' %}flashing{% endif %}" 
      {% if app.request.get('open') != 'change_password' %}
       style="display: none;"
      {% endif %}
     >
      <form class="nicelabels changepassword" action="{{ path('change_password', {'open':'change_password'}) }}" method="post" {{ form_enctype(form_password) }}>

        {% include "MuzichUserBundle:Security:change_password_form.html.twig" with { 
          'form': form_password
        } %}

        <input type="submit" class="button" value="{{ 'my_account.change_password_submit'|trans({}, 'userui') }}" />
      </form>
    </div>

    <h2 data-open="myaccount_favorites_email">{{ 'my_account.change_email'|trans({}, 'userui') }}</h2>

    <div id="myaccount_favorites_email" class="myaccount_part"
      {% if not change_email_form|form_has_errors %}
       style="display: none;"
      {% endif %}
    >
      <form class="nicelabels changeemail" action="{{ path('change_email_request') }}" method="post" {{ form_enctype(change_email_form) }}>

        {% include "MuzichUserBundle:User:change_email_form.html.twig" with { 
          'form': change_email_form
        } %}

        <input type="submit" class="button" value="{{ 'my_account.change_email_submit'|trans({}, 'userui') }}" />
      </form>
    </div>
    <div style="clear:both;"></div>
  
    <h2 data-open="myaccount_avatar">{{ 'my_account.avatar.title'|trans({}, 'userui') }}</h2>
  
    <div id="myaccount_avatar" class="myaccount_part"
       style="display: none;"
    >
      <form
          action="{{ path('user_update_avatar') }}"
          method="post" {{ form_enctype(avatar_form) }}
        >
        
          <p class="help">{{ 'my_account.avatar.help'|trans({}, 'userui') }}</p>
          {% include "MuzichUserBundle:User:avatar_form.html.twig" with { 
            'form': avatar_form
          } %}
      
          <input type="submit" class="button" value="{{ 'my_account.avatar.submit'|trans({}, 'userui') }}" />
      </form>
    </div>
    
    <h2 data-open="myaccount_preferences">{{ 'my_account.preferences.title'|trans({}, 'userui') }}</h2>
  
    <div id="myaccount_preferences" class="myaccount_part"
       style="display: none;"
    >
      <form
          action="{{ path('user_update_preferences') }}"
          method="post"
        >
        
          {% include "MuzichUserBundle:User:preference_form.html.twig" with { 
            'form': preferences_form
          } %}
      
          <input type="submit" class="button" value="{{ 'my_account.preferences.submit'|trans({}, 'userui') }}" />
      </form>
    </div>
    <div style="clear:both;"></div>
    
    <h2 data-open="myaccount_privacy">{{ 'my_account.privacy.title'|trans({}, 'userui') }}</h2>
  
    <div id="myaccount_privacy" class="myaccount_part"
       style="display: none;"
    >
      <form
        class="privacy"
        action="{{ path('user_update_privacy') }}"
        method="post"
      >
        
        <div class="field">
          <label for="user_privacy_favorites_publics" >{{ 'my_account.privacy.form.favorites'|trans({}, 'userui') }}</label>
          {{ form_widget(privacy_form.favorites_publics) }}
        </div>
        
        {{ form_rest(privacy_form) }}
      
          <input type="submit" class="button" value="{{ 'my_account.privacy.submit'|trans({}, 'userui') }}" />
      </form>
    </div>
    <div style="clear:both;"></div>
    
    
    <h2 data-open="myaccount_delete">{{ 'my_account.delete.title'|trans({}, 'userui') }}</h2>
  
    <div id="myaccount_delete" class="myaccount_part"
      {% if app.request.get('open') != 'delete' %}
        style="display: none;"
      {% endif %}
    >
      
      <p class="warning info">{{ 'my_account.delete.text'|trans({}, 'userui') }}</p>
      
      <form
        class="delete"
        action="{{ path('delete_user', {'open':'delete'}) }}"
        method="post"
      >
        
        <div class="field">
          {{ form_label(delete_form.current_password) }}
          {{ form_widget(delete_form.current_password) }}
        </div>
        
        {{ form_rest(delete_form) }}
      
          <input type="submit" class="button" value="{{ 'my_account.delete.submit'|trans({}, 'userui') }}" />
      </form>
    </div>
    <div style="clear:both;"></div>
    
  </div>
{% endblock %}