<div class="page-container">
  <!-- BEGIN CONTENT -->
  <div class="page-content-wrapper">
    <!-- BEGIN CONTENT BODY -->
    <!-- BEGIN PAGE HEAD-->
    <div class="page-head">
      <div class="container-fluid">
        <!-- BEGIN PAGE TITLE -->
        <div class="page-title">
          <h1>Usuarios </h1>
        </div>
        <!-- END PAGE TITLE -->
      </div>
    </div>
    <!-- END PAGE HEAD-->
    <!-- BEGIN PAGE CONTENT BODY -->
    <div class="page-content">
      <div class="container-fluid">
        <!-- BEGIN PAGE BREADCRUMBS -->
        <ul class="page-breadcrumb breadcrumb">
          <%= render_breadcrumbs :tag => :li, :separator => ' <i class="fa fa-circle"></i> ' %>
        </ul>
        <!-- END PAGE BREADCRUMBS -->
        <!-- BEGIN PAGE CONTENT INNER -->
        <div class="page-content-inner">
          <div id="notice">
          <% if success %>
            <div class="alert alert-success">
              <p><%= success %></p>
            </div>
          <% elsif warning %>
            <div class="alert alert-warning">
              <p><%= warning %></p>
            </div>
          <% end %>
          </div>
          <div class="row">
            <div class="col-md-12">
              <div class="portlet light ">
                <div class="portlet-title">
                  <div class="caption">
                    <i class="fa fa-list "></i>
                    <span class="caption-subject bold uppercase">Lista de usuarios del sistema</span>
                  </div>
                  <div class="actions">
                    <% if can? :create, User %>
                      <%= link_to new_user_path, {:class=>"btn bold green pull-right filtros"} do %> Nuevo Usuario <i class="fa fa-plus"></i>
                      <% end %>
                    <% end %>
                  </div>
                </div>
                <div class="portlet-body">
                  <input type='hidden' name='filter' id='filter' value='<%= @filter %>' >
                  <input type='hidden' name='current_page' id='current_page' value='<%= @current_page %>' >
                  <table class="table table-striped table-bordered table-hover tableadvanced" id="users_table">
                    <thead>
                      <tr>
                        <th>#</th>
                        <th>Usuario</th>
                        <th>Nombre</th>
                        <th>Tipo de usuario</th>
                        <th>Punto de venta</th>
                        <th>Almacén</th>
                        <th>Status</th>
                        <th width="15%">Acciones</th>
                      </tr>
                    </thead>
                    <tbody>
                      <% @users.each_with_index do |user, key| %>
                        <tr>
                          <td> <%= key +1 %> </td>
                          <td> <%= user.userid  %> </td>
                          <td> <%= user.first_name + ' ' + user.last_name %> </td>
                          <td>
                            <% case user.usertype %>
                            <% when "A" %>
                              <span class="text-danger">Administrador</span>
                            <% when "G" %>
                              <span class="text-warning">Gerente</span>
                            <% when "C" %>
                              <span class="text-info">Caja</span>
                            <% when "S" %>
                              <span class="text-info">Almacenista</span>
                            <% end %>
                          </td>
                          <td> <%= user.pointsale.name if user.pointsale.present?%> </td>
                          <td> <%= user.warehouse.name if user.warehouse.present?%> </td>
                          <td class="text-center">
                            <% if user.active? %>
                              <span class="label label-sm label-success"> <i class="fa fa-check"></i> Activo </span>
                            <% elsif user.inactive? %>
                              <span class="label label-sm label-danger"> <i class="fa fa-times"></i> Inactivo </span>
                            <% end %>
                          </td>
                          <td class="text-center">
                            <% if can? :update, User %>
                              <%= link_to edit_user_path(user), {:class=>"btn btn-icon-only btn-primary filtros", :title=>"Editar cliente"} do %>
                                <i class="fa fa-edit"></i>
                              <% end %>
                            <% end %>
                            <% if user.active? %>
                              <%= link_to user_update_status_path(user), :class=>"btn btn-icon-only default", :title=>"Desactivar usuario", data: { confirm: '¿Esta seguro de desactivar al usuario?', method: 'post'}  do %>
                                <i class="fa fa-toggle-off"></i>
                              <% end %>
                            <% elsif user.inactive? %>
                              <%= link_to user_update_status_path(user), :class=>"btn btn-icon-only green-jungle", :title=>"Activar usuario", data: { confirm: '¿Esta seguro de activar al usuario?', method: 'post'}  do %>
                                <i class="fa fa-toggle-on"></i>
                              <% end %>
                            <% end %>
                          </td>
                        </tr>
                      <% end %>
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
          </div>
        </div>
        <!-- END PAGE CONTENT INNER -->
      </div>
    </div>
    <!-- END PAGE CONTENT BODY -->
    <!-- END CONTENT BODY -->
  </div>
  <!-- END CONTENT -->
</div>
