{{header}}{{column_left}}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-author" data-toggle="tooltip" title="{{button_save}}" class="btn btn-primary"><i class="fa fa-save"></i></button>
        <a href="{{cancel}}" data-toggle="tooltip" title="{{button_cancel}}" class="btn btn-default"><i class="fa fa-reply"></i></a>
      </div>
      <h1>{{heading_title}}</h1>
      <ul class="breadcrumb">
        {% for breadcrumb in breadcrumbs %}
        <li><a href="{{breadcrumb.href}}">{{breadcrumb.text}}</a></li>
        {% endfor %}
      </ul>
    </div>
  </div>
  <div class="container-fluid">
    {% if error_warning %}
    <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> {{error_warning}}
      <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    {% endif %}
    <div class="panel panel-default">
      <div class="panel-heading">
        <h3 class="panel-title"><i class="fa fa-pencil"></i> {{text_form}}</h3>
      </div>
      
      <div class="panel-body">
        <form action="{{action}}" method="post" enctype="multipart/form-data" id="form-author" class="form-horizontal">
          <ul class="nav nav-tabs">
            <li class="active"><a href="#tab-general" data-toggle="tab">{{tab_general}}</a></li>
            <li><a href="#tab-data" data-toggle="tab">{{tab_data}}</a></li>
          </ul>
          <div class="tab-content">
            <div class="tab-pane active" id="tab-general">
              <style>
                #input_username .clear{
                    display: none;
                }

                #input_username.input-group .clear{
                    display: block;
                }
              </style>
              <div class="form-group required">
                <label class="col-sm-2 control-label" for="input-username">{{entry_username}}</label>
                <div class="col-sm-10">
                  <div id="input_username">
                      <input type="text" name="username" value="{{username}}" placeholder="{{entry_username}}" id="input-username" class="form-control" />
                      <span class="input-group-btn">
                        <a class="btn btn-danger clear"><i class="fa fa-close"></i></a>
                      </span>
                   </div>
                   {% if error_username %}
                    <div class="text-danger">{{error_username}}</div>
                    {% endif %}
                   <div class="bs-callout bs-callout-warning user-info m-t">
                        {{help_user_editing}}
                   </div>
                  <input type="hidden" name="user_id" value="{{user_id}}" id="input-user_id" class="form-control" />
                </div>
              </div>
              <ul class="nav nav-tabs" id="language">
                {% for language in languages %}
                <li><a href="#language{{language.language_id}}" data-toggle="tab"><img src="{{language.flag}}" title="{{language.name}}" /> {{language.name}}</a></li>
                {% endfor %}
              </ul>
              <div class="tab-content">
                {% for language in languages %}
                <div class="tab-pane" id="language{{language.language_id}}">
                  <div>
                    <div class="form-group required">
                      <label class="col-sm-2 control-label" for="input-description{{language.language_id}}">{{entry_author_name}}</label>
                      <div class="col-sm-10">
                        <input type="text" class="form-control" name="author_description[{{language.language_id}}][name]" placeholder="{{entry_author_name}}" id="input-name{{language.language_id}}" value="{{ author_description[language.language_id] ? author_description[language.language_id].name : ''}}">
                        {% if error_name[language.language_id] %}
                        <div class="text-danger">{{error_name[language.language_id]}}</div>
                        {% endif %}
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-sm-2 control-label" for="input-short-description{{language.language_id}}">{{entry_short_description}}</label>
                      <div class="col-sm-10">
                        <textarea class="form-control" name="author_description[{{language.language_id}}][short_description]" placeholder="{{entry_short_description}}" id="input-short-description{{language.language_id}}">{{ author_description[language.language_id] ? author_description[language.language_id].short_description : ''}}</textarea>
                      </div>
                    </div>
                    <div class="form-group">
                      <label class="col-sm-2 control-label" for="input-description{{language.language_id}}">{{entry_description}}</label>
                      <div class="col-sm-10">
                        <textarea class="form-control d_visual_designer summernote" data-toggle="summernote" name="author_description[{{language.language_id}}][description]" placeholder="{{entry_short_description}}" id="input-description{{language.language_id}}">{{ author_description[language.language_id] ? author_description[language.language_id].description : ''}}</textarea>
                      </div>
                    </div>
					<div class="form-group required">
                        <label class="col-sm-2 control-label" for="input-meta-title{{language.language_id}}">{{entry_meta_title}}</label>
                        <div class="col-sm-10">
                            <input type="text" name="author_description[{{language.language_id}}][meta_title]" value="{{ author_description[language.language_id] ? author_description[language.language_id].meta_title : ''}}" placeholder="{{entry_meta_title}}" id="input-meta-title{{language.language_id}}" class="form-control" />
                            {% if error_meta_title[language.language_id] %}
                            <div class="text-danger">{{error_meta_title[language.language_id]}}</div>
                            {% endif %}
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="input-meta-description{{language.language_id}}">{{entry_meta_description}}</label>
                        <div class="col-sm-10">
                            <textarea name="author_description[{{language.language_id}}][meta_description]" rows="5" placeholder="{{entry_meta_description}}" id="input-meta-description{{language.language_id}}" class="form-control">{{author_description[language.language_id] ? author_description[language.language_id].meta_description : ''}}</textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label" for="input-meta-keyword{{language.language_id}}">{{entry_meta_keyword}}</label>
                        <div class="col-sm-10">
                            <textarea name="author_description[{{language.language_id}}][meta_keyword]" rows="5" placeholder="{{entry_meta_keyword}}" id="input-meta-keyword{{language.language_id}}" class="form-control">{{author_description[language.language_id] ? author_description[language.language_id].meta_keyword : ''}}</textarea>
                        </div>
                     </div>
                   </div> 
                </div>
                {% endfor %}
              </div>
            </div>
  
            <div class="tab-pane" id="tab-data">
              <div class="form-group">
                  <label class="col-sm-2 control-label" for="input-user-group">{{entry_user_group}}</label>
                  <div class="col-sm-10">
                    <select name="user_group_id" id="input-user-group" class="form-control">
                      {% for user_group in user_groups %}
                      {% if user_group.user_group_id == user_group_id %}
                      <option value="{{user_group.user_group_id}}" selected="selected">{{user_group.name}}</option>
                      {% else %}
                      <option value="{{user_group.user_group_id}}">{{user_group.name}}</option>
                      {% endif %}
                      {% endfor %}
                    </select>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label" for="input-user-group">{{entry_author_group}}</label>
                  <div class="col-sm-10">
                    <select name="author_group_id" id="input-user-group" class="form-control">
                      {% for author_group in author_groups %}
                      {% if author_group.author_group_id == author_group_id %}
                      <option value="{{author_group.author_group_id}}" selected="selected">{{author_group.name}}</option>
                      {% else %}
                      <option value="{{author_group.author_group_id}}">{{author_group.name}}</option>
                      {% endif %}
                      {% endfor %}
                    </select>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-2 control-label" for="input-image">{{entry_image}}</label>
                  <div class="col-sm-10"><a href="" id="thumb-image" data-toggle="image" class="img-thumbnail"><img src="{{thumb}}" id="image_user" alt="" title="" data-placeholder="{{placeholder}}" /></a>
                    <input type="hidden" name="image" value="{{image}}" id="input-image" />
                  </div>
                </div>
               
                <div class="form-group required">
                  <label class="col-sm-2 control-label" for="input-firstname">{{entry_firstname}}</label>
                  <div class="col-sm-10">
                    <input type="text" name="firstname" value="{{firstname}}" placeholder="{{entry_firstname}}" id="input-firstname" class="form-control" />
                    {% if error_firstname %}
                    <div class="text-danger">{{error_firstname}}</div>
                    {% endif %}
                  </div>
                </div>
                <div class="form-group required">
                  <label class="col-sm-2 control-label" for="input-lastname">{{entry_lastname}}</label>
                  <div class="col-sm-10">
                    <input type="text" name="lastname" value="{{lastname}}" placeholder="{{entry_lastname}}" id="input-lastname" class="form-control" />
                    {% if error_lastname %}
                    <div class="text-danger">{{error_lastname}}</div>
                    {% endif %}
                  </div>
                </div>
                <div class="form-group required">
                  <label class="col-sm-2 control-label" for="input-password">{{entry_password}}</label>
                  <div class="col-sm-10">
                    <input type="password" name="password" value="" placeholder="{{entry_password}}" id="input-password" class="form-control" autocomplete="off" />
                    {% if error_password %}
                    <div class="text-danger">{{error_password}}</div>
                    {% endif %}
                  </div>
                </div>
                <div class="form-group required">
                  <label class="col-sm-2 control-label" for="input-confirm">{{entry_confirm}}</label>
                  <div class="col-sm-10">
                    <input type="password" name="confirm" value="" placeholder="{{entry_confirm}}" id="input-confirm" class="form-control" />
                    {% if error_confirm %}
                    <div class="text-danger">{{error_confirm}}</div>
                    {% endif %}
                  </div>
                </div>
              </div>
          </div>
        </form>
      </div>
    </div>
  </div>
  <script type="text/javascript">
    $('#language a:first').tab('show');
    //--></script>
        <script type="text/javascript"><!--
            {% for language in languages %}
                {% if not store_2302 %}
                    $("#input-description{{language.language_id}}").summernote({ height: 300 });
                {% endif %}
            {% endfor %}
            //--></script>
            <script type="text/javascript">
            $('input[name=\'username\']').autocomplete({
              source: function(request, response) {
                $.ajax({
                  url: '{{author_autocomplete}}&filter_name=' +  encodeURIComponent(request),
                  dataType: 'json',
                  success: function(json) {
                    response($.map(json, function(item) {
                      return {
                        label: item['username'],
                        value: item['user_id'],
                        user_group_id: item['user_group_id'],
                        firstname: item['firstname'],
                        lastname: item['lastname'],
                        image: item['image'],
                        thumb: item['thumb']
                    }
                }));
                }
            });
            },

            'select': function(item) {
               $('input[name=\'username\']').val(item['label']);
               $('input[name=\'username\']').val(item['label']);
               $('input[name=\'firstname\']').val(item['firstname']);
               $('input[name=\'lastname\']').val(item['lastname']);
               $('input[name=\'user_id\']').val(item['value']);
               $('input[name=\'image\']').val(item['image']);
               $('img[id=\'image_user\']').attr('src',item['thumb']);
               $('select[name=\'user_group_id\'] > option').removeAttr('selected');
               $('select[name=\'user_group_id\'] > option[value=\''+item['user_group_id']+'\']').attr('selected','true');
               $('#input_username').addClass('input-group');
           }


       });
$(document).on('click', '.clear', function() {
   $('input[name=\'username\']').val('');
   $('input[name=\'firstname\']').val('');
   $('input[name=\'lastname\']').val('');
   $('input[name=\'user_id\']').val('');
   $('input[name=\'image\']').val('{{image}}');
   $('img[id=\'image_user\']').attr('src', '{{thumb}}');
   $('select[name=\'user_group_id\'] > option').removeAttr('selected');
   $('#input_username').removeClass('input-group');

});
</script>
</div>
{{footer}}
