{{ header }}{{ column_left }}
<div id="content">
  <div class="page-header">
    <div class="container-fluid">
      <div class="pull-right">
        <button type="submit" form="form-user" 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 alert-dismissible"><i class="fa fa-exclamation-circle"></i> {{ error_warning }}
        <button type="button" class="close" data-dismiss="alert">&times;</button>
      </div>
    {% endif %}
    <div class="row">
      <div class="col-md-9 col-md-pull-3 col-sm-12">
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title"><i class="fa fa-list"></i> {{ text_list }}</h3>
          </div>
          <div class="panel-body">
            <form action="{{ action }}" method="post" enctype="multipart/form-data" id="form-user" class="form-horizontal">
              <div class="form-group required">
                <label class="col-sm-2 control-label" for="input-username">{{ entry_username }}</label>
                <div class="col-sm-10">
                  <input type="text" name="username" value="{{ username }}" placeholder="{{ entry_username }}" id="input-username" class="form-control"/>
                  {% if error_username %}
                    <div class="text-danger">{{ error_username }}</div>
                  {% endif %}
                </div>
              </div>
              <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 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-email">{{ entry_email }}</label>
                <div class="col-sm-10">
                  <input type="text" name="email" value="{{ email }}" placeholder="{{ entry_email }}" id="input-email" class="form-control"/>
                  {% if error_email %}
                    <div class="text-danger">{{ error_email }}</div>
                  {% endif %}
                </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 }}" 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-password">{{ entry_password }}</label>
                <div class="col-sm-10">
                  <input type="password" name="password" value="{{ password }}" 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="{{ confirm }}" placeholder="{{ entry_confirm }}" id="input-confirm" class="form-control"/>
                  {% if error_confirm %}
                    <div class="text-danger">{{ error_confirm }}</div>
                  {% endif %}
                </div>
              </div>
              <div class="form-group">
                <label class="col-sm-2 control-label" for="input-status">{{ entry_status }}</label>
                <div class="col-sm-10">
                  <select name="status" id="input-status" class="form-control">
                    {% if status %}
                      <option value="0">{{ text_disabled }}</option>
                      <option value="1" selected="selected">{{ text_enabled }}</option>
                    {% else %}
                      <option value="0" selected="selected">{{ text_disabled }}</option>
                      <option value="1">{{ text_enabled }}</option>
                    {% endif %}
                  </select>
                </div>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
    {% if username %}
      <div class="col-md-9 col-md-pull-3 col-sm-12">
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title"><i class="fa fa-list"></i> {{ text_login }}</h3>
          </div>
          <div class="panel-body">
            <div id="login"></div>
          </div>
        </div>
      </div>
    {% endif %}
  </div>
  <script type="text/javascript"><!--
      $('#login').delegate('.pagination a', 'click', function (e) {
          e.preventDefault();

          $('#login').load(this.href);
      });

      $('#login').load('index.php?route=user/user/getLogins&user_token={{ user_token }}');

      $('#login').on('click', '.btn-success, .btn-danger', function (e) {
          e.preventDefault();

          var element = this;

          $.ajax({
              url: $(element).attr('href'),
              dataType: 'json',
              beforeSend: function () {
                  $(element).button('loading');
              },
              complete: function () {
                  $(element).button('reset');
              },
              success: function () {
                  $('.alert-dismissible').remove();

                  $('#login').load('index.php?route=user/user/getLogins&user_token={{ user_token }}');
              },
              error: function (xhr, ajaxOptions, thrownError) {
                  alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
              }
          });
      });
  //--></script>
</div>
{{ footer }}