<section class="heading b-b">
  <div class="row no-gutter">
    <div class="col-xs-2 col-sm-2 col-md-1">
      <section class="heading-btn">
        <a href="#" ng-click="backPrevLocation($event)"><i class="fa fa-long-arrow-left "></i></a>
      </section>
    </div>
    <div class="col-xs-10 col-sm-10 col-md-8 b-l">
      <section class="heading-title">
        <h1 translate>{{ 'users_management' }}</h1>
      </section>
    </div>

  </div>
</section>

<section class="m-lg">
  <div class="row">
      <div class="col-md-12">
          <uib-tabset justified="true">

              <uib-tab heading="{{ 'members' | translate }}">
                  <div class="col-md-5 m-t-lg">
                      <div class="form-group">
                          <div class="input-group">
                              <span class="input-group-addon"><i class="fa fa-filter"></i></span>
                              <input type="text" ng-model="searchMember" class="form-control" placeholder="{{ 'search_for_an_user' | translate }}">
                          </div>
                      </div>
                  </div>
                  <div class="col-md-12">
                      <button type="button" class="btn btn-warning m-t m-b" ui-sref="app.admin.members_new" translate>{{ 'add_a_new_member' }}</button>
                      <div class="pull-right">
                          <a class="btn btn-default" ng-href="api/members/export_members.xls" target="_blank">
                              <i class="fa fa-file-excel-o"></i> {{ 'members' | translate }}
                          </a>
                          <a class="btn btn-default" ng-href="api/members/export_subscriptions.xls" target="_blank" ng-if="!fablabWithoutPlans">
                              <i class="fa fa-file-excel-o"></i> {{ 'subscriptions' | translate }}
                          </a>
                          <a class="btn btn-default" ng-href="api/members/export_reservations.xls" target="_blank">
                              <i class="fa fa-file-excel-o"></i> {{ 'reservations' | translate }}
                          </a>
                      </div>


                      <table class="table">
                          <thead>
                              <tr>
                                  <th style="width:15%"><a href="" ng-click="setOrderMember('last_name')">{{ 'surname' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-alpha-asc': orderMember=='last_name', 'fa fa-sort-alpha-desc': orderMember=='-last_name', 'fa fa-arrows-v': orderMember }"></i></a></th>

                                  <th style="width:15%"><a href="" ng-click="setOrderMember('first_name')">{{ 'first_name' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-alpha-asc': orderMember=='first_name', 'fa fa-sort-alpha-desc': orderMember=='-first_name', 'fa fa-arrows-v': orderMember }"></i></a></th>

                                  <th style="width:15%"><a href="" ng-click="setOrderMember('email')">{{ 'email' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-alpha-asc': orderMember=='email', 'fa fa-sort-alpha-desc': orderMember=='-email', 'fa fa-arrows-v': orderMember }"></i></a></th>

                                  <th style="width:10%"><a href="" ng-click="setOrderMember('profile.phone')">{{ 'phone' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-numeric-asc': orderMember=='profile.phone', 'fa fa-sort-numeric-desc': orderMember=='-profile.phone', 'fa fa-arrows-v': orderMember }"></i></a></th>

                                  <th style="width:20%"><a href="" ng-click="setOrderMember('group.name')">{{ 'user_type' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-alpha-asc': orderMember=='group.name', 'fa fa-sort-alpha-desc': orderMember=='-group.name', 'fa fa-arrows-v': orderMember }"></i></a></th>

                                  <th style="width:15%"><a href="" ng-click="setOrderMember('subscribed_plan.base_name')">{{ 'subscription' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-alpha-asc': orderMember=='subscribed_plan.base_name', 'fa fa-sort-alpha-desc': orderMember=='-subscribed_plan.base_name', 'fa fa-arrows-v': orderMember }"></i></a></th>

                                  <th style="width:10%"></th>
                              </tr>
                          </thead>
                          <tbody>
                              <tr ng-repeat="member in members | filter:searchMember | orderBy:orderMember">
                                  <td class="text-c">{{ member.profile.last_name }}</td>
                                  <td class="text-c">{{ member.profile.first_name }}</td>
                                  <td>{{ member.email }}</td>
                                  <td>{{ member.profile.phone }}</td>
                                  <td class="text-u-c text-sm">{{ member.group.name }}</td>
                                  <td>{{ member.subscribed_plan | humanReadablePlanName }}</td>
                                  <td>
                                      <div class="buttons">
                                          <button class="btn btn-default" ui-sref="app.admin.members_edit({id: member.id})">
                                              <i class="fa fa-edit"></i> {{ 'edit' | translate }}
                                          </button>
                                      </div>
                                  </td>
                              </tr>
                          </tbody>
                      </table>
                  </div>
              </uib-tab>

              <uib-tab heading="{{ 'administrators' | translate }}">
                  <div class="col-md-5 m-t-lg">
                      <div class="form-group">
                          <div class="input-group">
                              <span class="input-group-addon"><i class="fa fa-filter"></i></span>
                              <input type="text" ng-model="searchFilter" class="form-control" placeholder="{{ 'search_for_an_administrator' | translate }}">
                          </div>
                      </div>
                  </div>
                  <div class="col-md-12">
                      <button type="button" class="btn btn-warning m-t m-b" ui-sref="app.admin.admins_new" translate>{{ 'add_a_new_administrator' }}</button>

                      <table class="table">
                          <thead>
                          <tr>
                              <th style="width:15%"><a href="" ng-click="setOrderAdmin('profile_attributes.last_name')">{{ 'surname' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-alpha-asc': orderAdmin =='profile_attributes.last_name', 'fa fa-sort-alpha-desc': orderAdmin =='-profile_attributes.last_name', 'fa fa-arrows-v': orderAdmin  }"></i></a></th>

                              <th style="width:15%"><a href="" ng-click="setOrderAdmin('profile_attributes.first_name')">{{ 'first_name' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-alpha-asc': orderAdmin =='profile_attributes.first_name', 'fa fa-sort-alpha-desc': orderAdmin =='-profile_attributes.first_name', 'fa fa-arrows-v': orderAdmin  }"></i></a></th>

                              <th style="width:15%"><a href="" ng-click="setOrderAdmin('email')">{{ 'email' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-alpha-asc': orderAdmin =='email', 'fa fa-sort-alpha-desc': orderAdmin =='-email', 'fa fa-arrows-v': orderAdmin  }"></i></a></th>

                              <th style="width:10%"><a href="" ng-click="setOrderAdmin('profile_attributes.phone')">{{ 'phone' | translate }} <i class="fa fa-arrows-v" ng-class="{'fa fa-sort-numeric-asc': orderAdmin =='profile_attributes.phone', 'fa fa-sort-numeric-desc': orderAdmin =='-profile_attributes.phone', 'fa fa-arrows-v': orderAdmin  }"></i></a></th>
                              <th style="width:10%"></th>
                          </tr>
                          </thead>
                          <tbody>
                          <tr ng-repeat="admin in admins | filter:searchFilter | orderBy: orderAdmin">
                              <td class="text-c">{{ admin.profile_attributes.last_name }}</td>
                              <td class="text-c">{{ admin.profile_attributes.first_name }}</td>
                              <td>{{ admin.email }}</td>
                              <td>{{ admin.profile_attributes.phone }}</td>
                              <td>
                                <button class="btn btn-danger" ng-if="admin.id != currentUser.id" ng-click="destroyAdmin(admins, admin)">
                                  <i class="fa fa-trash-o"></i>
                                </button>
                              </td>
                          </tr>
                          </tbody>
                      </table>
                  </div>
              </uib-tab>

              <uib-tab heading="{{ 'groups' | translate }}">
                  <div ui-view="groups"></div>
              </uib-tab>

              <uib-tab heading="{{ 'tags' | translate }}">
                  <div ui-view="tags"></div>
              </uib-tab>

              <uib-tab heading="{{ 'authentication' | translate }}">

                  <div ui-view="authentification"></div>
              </uib-tab>
          </uib-tabset>
      </div>
  </div>
</section>
