<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>Almacenes</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 almacenes</span>
									</div>
									<div class="actions">
										<% if can? :create, User %>
											<%= link_to new_warehouse_path, {:class=>"btn bold green pull-right filtros"} do %> Nuevo almacén <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 width="10%">#</th>
												<th>Nombre</th>
												<th>Prefijo</th>
												<th>Status</th>
												<th width="20%">Acciones</th>
											</tr>
										</thead>
										<tbody>
											<% @warehouses.each_with_index do |warehouse, key| %>
												<tr>
													<td> <%= key +1 %> </td>
													<td> <%= warehouse.name  %> </td>
													<td> <%= warehouse.prefix  %> </td>
													<td class="text-center">
														<% if warehouse.active? %>
															<span class="label label-sm label-success"> <i class="fa fa-check"></i> Activo </span>
														<% elsif warehouse.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, Warehouse %>
															<%= link_to edit_warehouse_path(warehouse), {:class=>"btn btn-icon-only btn-primary filtros", :title=>"Editar almacen"} do %>
																<i class="fa fa-edit"></i>
															<% end %>
														<% end %>
														<% if warehouse.active? %>
															<%= link_to warehouse_update_status_path(warehouse), :class=>"btn btn-icon-only default", :title=>"Desactivar almacen", data: { confirm: '¿Esta seguro de desactivar el almacen?', method: 'post'}  do %>
																<i class="fa fa-toggle-off"></i>
															<% end %>
														<% elsif warehouse.inactive? %>
															<%= link_to warehouse_update_status_path(warehouse), :class=>"btn btn-icon-only green-jungle", :title=>"Activar almacen", data: { confirm: '¿Esta seguro de activar el almacen?', 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>
<script>
	$(document).on("page:change", function() {
		 App.init();
	});
</script>
