<header>
	<h2 class="text-center">Reporte existencias del <%= location.is_a?(Pointsale) ? 'punto de venta ' : 'almacén ' %> <%= location.name.downcase.camelize %></h2>
	<h4 style="margin-top:5px;margin-bottom:5px;">Fecha: <%= l(Time.now, :format => '%d/%m/%y %I:%M %p') %> </h4>

	<% if category.present? %>
		<h4 style="margin-top:5px;margin-bottom:5px;">Línea: <%= Category.find(category).category %> </h4>
	<% end %>

	<% if sub_category.present? %>
		<h4 style="margin-top:5px;margin-bottom:5px;">Sublínea: <%= Category.find(sub_category).category %> </h4>
	<% end %>	

	<% if search.present? %>
		<h4 style="margin-top:5px;margin-bottom:5px;">Busqueda: <%= search %> </h4>
	<% end %>	
	
</header>
<table style="width:100% !important">
	<thead>
		<tr>
			<th class="text-center">PRODUCTO</th>
			<th class="text-left">LÍNEA</th>
			<th class="text-left">SUBLÍNEA</th>
			<th class="text-center">EXISTENCIA</th>
		</tr>
	</thead>
	<tbody>
		<% stock.each do |ap| %>
			<% category = ap.categories[0] %>
			<tr class="border-1-px">
				<td> 
				    <strong> <%= ap.product.name %> </strong>
				    &nbsp;<%= ap.product.display_attributes %>
			    </td>	    
				<td> <%= category.parent_id == 0 ? category.category : category.parent.category %> </td>
				<td> <%= category.parent_id != 0 ? category.category : ' ' %> </td>
				<td class="text-center"> <%= ap.stock %> </td>
			</tr>
		<% end %>
	</tbody>
</table>

 




