{% extends 'old-bootstrap-modal-layout.html.twig' %}

{% set modalSize = 'large' %}

{% block title %}{{'编辑用户信息'|trans}}{% endblock %}
{% block body %}

<form id="user-edit-form" class="form-horizontal" method="post" action="{{ url('admin_user_edit', {id:user.id}) }}">

  <div class="row form-group">
    <div class="col-md-2 control-label">
      <label for="truename">{{'姓名'|trans}}</label>
    </div>
    <div class="col-md-7 controls">
      <input type="text" id="truename" name="truename" class="form-control" value="{{profile.truename}}" >
    </div>
  </div>

  <div class="row form-group">
    <div class="col-md-2 control-label">
      <label for="gender">{{'性别'|trans}}</label>
    </div>
    <div class="col-md-7 controls radios">
      <div id="gender">
        <input type="radio" id="gender_0" name="gender" value="male"
        {% if profile.gender == 'male' %} checked="checked" {% endif %}>
        <label for="gender_0">{{'男'|trans}}</label>

        <input type="radio" id="gender_1" name="gender" value="female"
        {% if profile.gender == 'female' %} checked="checked" {% endif %}>
        <label for="gender_1">{{'女'|trans}}</label>
      </div>

    </div>
  </div>

    <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="idcard">{{'身份证号'|trans}}</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="idcard" name="idcard" class="form-control" value="{{profile.idcard}}">
     </div>
    </div>

    {% if (user.verifiedMobile|length) > 0 %}
      <div class="row form-group">
        <div class="col-md-2 control-label"> 
          <label for="mobile">{{'手机号码'|trans}}</label>
        </div>
        <div class="col-md-7 controls">
          <div class="control-text"> {{user.verifiedMobile|default('')}}<span class="text-success">({{'已绑定'|trans}})</span> </div>
       </div>
      </div>
    {% else %}
      <div class="row form-group">
        <div class="col-md-2 control-label"> 
          <label for="mobile">{{'手机号码'|trans}}</label>
        </div>
        <div class="col-md-7 controls">
          <input type="text" id="mobile" name="mobile" class="form-control" value="{{profile.mobile|default('')}}">
       </div>
      </div>
    {% endif %}

    <div class="row form-group">
        <div class="col-md-2 control-label"> 
          <label for="company">{{'公司'|trans}}</label>
        </div>
        <div class="col-md-7 controls">
          <input type="text" id="company" name="company" class="form-control" value="{{profile.company}}">
       </div>
    </div>
    
    <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="job">{{'职业'|trans}}</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="job" name="job" class="form-control" value="{{profile.job}}">
     </div>
    </div>

    <p></p>
    <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="title">{{'头衔'|trans}}</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="title" name="title" class="form-control" value="{{profile.title}}">
     </div>
    </div>
    <p></p>
    <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="signature">{{'个人签名'|trans}}</label>
      </div>
      <div class="col-md-7 controls">
        <textarea type="text" rows="4" maxlength="80" id="signature" name="signature" class="form-control">{{profile.signature}}</textarea>
     </div>
    </div>
    <p></p>
    <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="about">{{'自我介绍'|trans}}</label>
      </div>
      <div class="col-md-7 controls">
        <textarea id="about" name="about" data-image-upload-url="{{ path('editor_upload', {token:upload_token('default')}) }}">{{profile.about}}</textarea>
      </div>
    </div>
    <p></p>
    <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="site">{{'个人主页'|trans}}</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="site" name="site" class="form-control" value="{{profile.site}}">
     </div>
    </div>
    <p></p>
  <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="weibo">{{'微博'|trans}}</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="weibo" name="weibo" class="form-control" value="{{profile.weibo}}">
     </div>
    </div>
    <p></p>
    <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="qq">QQ</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="qq" name="qq" class="form-control" value="{{profile.qq}}">
     </div>
    </div>
    <p></p>
    <div class="row form-group">
      <div class="col-md-2 control-label"> 
        <label for="weixin">{{'微信'|trans}}</label>
      </div>
      <div class="col-md-7 controls">
        <input type="text" id="weixin" name="weixin" class="form-control" value="{{profile.weixin}}">
     </div>
    </div> 

    <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">           

{% if fields %}
          <hr>
          {% for field in fields %}
          {% if field.type=="text" %}
          <div class="form-group">
            <label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
            <div class="col-md-7 controls">
              <textarea id="{{field.fieldName}}" name="{{field.fieldName}}" class="{{field.type}} form-control" >{{ profile[field.fieldName]|default('') }}</textarea>
              <div class="help-block" style="display:none;"></div>
            </div>
          </div>
          {% elseif field.type=="int" %}
          <div class="form-group">
            <label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
            <div class="col-md-7 controls">
              <input type="text" id="{{field.fieldName}}" placeholder="{{'最大值为9位整数'|trans}}" name="{{field.fieldName}}" class="{{field.type}} form-control"  value="{{ profile[field.fieldName]|default('') }}">
              <div class="help-block" style="display:none;"></div>
            </div>
          </div>
          {% elseif field.type=="float" %}
          <div class="form-group">
            <label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
            <div class="col-md-7 controls">
              <input type="text" id="{{field.fieldName}}" placeholder="{{'保留到2位小数'|trans}}" name="{{field.fieldName}}" class="{{field.type}} form-control" value="{{ profile[field.fieldName]|default('') }}">
              <div class="help-block" style="display:none;"></div>
            </div>
          </div>
          {% elseif field.type=="date" %}
          <div class="form-group">
            <label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
            <div class="col-md-7 controls">
              <input type="text" id="{{field.fieldName}}" name="{{field.fieldName}}" class="{{field.type}} form-control"   value="{% if profile[field.fieldName] %}{{profile[field.fieldName]}}{% endif %}">
              <div class="help-block" style="display:none;"></div>
            </div>
          </div>
          {% elseif field.type=="varchar" %}
          <div class="form-group">
            <label for="{{field.fieldName}}" class="col-md-2 control-label">{{field.title}}</label>
            <div class="col-md-7 controls">
              <input type="text" id="{{field.fieldName}}" name="{{field.fieldName}}" class="form-control"  value="{{ profile[field.fieldName]|default('') }}">
              <div class="help-block" style="display:none;"></div>
            </div>
          </div>
          {% endif %}
          {% endfor %}
          {% endif %}

</form>
{% endblock %}

{% block footer %}
  <button id="edit-user-btn" data-submiting-text="{{'正在提交'|trans}}" type="submit" class="btn btn-primary pull-right" data-toggle="form-submit" data-target="#user-edit-form">{{'保存'|trans}}</button>
  <button type="button" class="btn btn-link pull-right" data-dismiss="modal">{{'取消'|trans}}</button>
  
  <script>app.load('user/edit-modal');</script>
{% endblock %}