<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>Merma de productos </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 mermas</span>
									</div>
									<div class="actions">
										<% if current_user.usertype != 'A' %>
										<%= link_to new_product_waste_path, {:class=>"btn bold green pull-right"} do %> Nueva Merma de producto <i class="fa fa-plus"></i>
										<% end %>
										<% end %>
									</div>
								</div>
								<div class="portlet-body">
									<table class="table table-striped table-bordered table-hover tableadvanced">
										<thead>
											<tr>
												<th>#</th>
												<th>SKU</th>
												<th>Producto</th>
												<th>Merma</th>
												<th>Motivo</th>
												<th>Registró</th>
												<th>Fecha</th>
												<% if current_user.usertype == 'A'%>
													<th>Localización</th>
												<% end %>
												<th>Status</th>
												<th>Acciones</th>
											</tr>
										</thead>
										<tbody>
											<% @product_wastes.each_with_index do |product_waste, key| %>
											<tr>
												<td><%= key +1 %></td>
												<td><%= product_waste.product.sku %> </td>
												<td>
													<%= product_waste.product.name %><br>
													<%= product_waste.product.display_attributes %>
												</td>
												<td><%= product_waste.quantity %> </td>
												<td><%= product_waste.reason %> </td>
												<td><%= product_waste.user.first_name %> </td>
												<td><%= l(product_waste.created_at, :format => '%d/%B/%Y') %></td>
												<% if current_user.usertype == 'A'%>
													<td> <%= product_waste.pointsale.present? ?  product_waste.pointsale.name : product_waste.warehouse.name %> </td>
												<% end %>
												<td class="text-center">
													<% case product_waste.status %>
													<% when "active"%>
														<i class="fa fa-check font-green"></i>
													<% when "inactive"%>
														<i class="fa fa-close font-red"></i>                         
													<% end %>
												</td>
												<td class="text-center">
													<%= link_to product_waste, method: :delete, :class => "btn btn-icon-only btn-danger", :title => "Eliminar merma", data: { confirm: '¿Esta seguro de eliminar la merma del producto?'}   do %> 
														<i class="fa fa-trash-o"></i>
													<% 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>
<!-- END CONTAINER