<ul class="list-group">
	<li class="list-group-item">
		<ul class="nav nav-pills alt-pills float-right mini-labels">
			<form method="get">
				<li class="nav-item float-left mr-3">
					<label>Almacen</label>
					<select name ="id_almacen" class="form-control select-id-almacen" onchange="this.form.submit()">
						<option value="0">Todos</option>
						<?php
							foreach($almacenes as $k => $v) {
								$selected = '';
								if (!empty($id_almacen)) {
									if ($id_almacen == $k) {
										$selected =' selected="selected"';
									}
								}
								echo '<option value="' . $k . '"' . $selected . '>' . $v . '</option>';
							}
						?>
					</select>
				</li>
				<li class="nav-item float-left mr-3">
				<label>Fecha</label>
					<input type="date" name="fecha" id="fecha" class="form-control input-fecha" value="<?php echo $fecha; ?>" onchange="this.form.submit()">
				</li>
			</form>
		</ul>
	</li>
	<li class="list-group-item">
		<h4>Inventarios Realizados</h4>
	</li>
	<?php
	if(!empty($inventarios)) {
		foreach($inventarios as $k => $is) {
		?>
		<li class="list-group-item">
			<h4 class="clickable" data-toggle="collapse" href="#inventarios-<?php echo $k; ?>" aria-expanded="true"><?php echo fecha($k) . ' ('.count($is).')'?></h4>
			<div id="inventarios-<?php echo $k; ?>" class="table-responsive collapse show">
				<table class="table table-striped lista-almacenes-productos">
					<thead>
						<tr>
							<th class="text-center">Id</th>
							<th>Producto</th>
							<th>Almacen</th>
							<th class="text-center">Stock Sistema</th>
							<th class="text-center">Stock Encontrado</th>
							<th class="text-center">Fecha Revisión</th>
							<th>Revisor</th>
						</tr>
					</thead>
					<tbody>
						<?php
						foreach($is as $inv) {
							?>
							<tr class="inventario-<?php echo $inv['id']; ?>">
								<td class="text-center">
									<?php echo $inv['id']; ?>
								</td>
								<td>
									<?php
									if (!empty($ps_imagenes[$inv['ps_id']])) {
										echo ps_image($ps_imagenes[$inv['ps_id']]);
									} 
									?>
									<a target="_blank" href="/productos/detalle/<?php echo $inv['id_producto']; ?>">
										<span class="nombre"><?php echo $inv['nombre']; ?></span>
									</a>
								</td>

								<td><span class="tt" title="Almacén"><?php echo $almacenes[$inv['id_almacen']]; ?></span></td>

								<td class="text-center stock-sistema"><span class=" tt" title="Stock Sistema"><?php echo $inv['stock_sistema']; ?></span></td>

								<td class="text-center stock-encontrado"><span class="tt" title="Stock encontrado"><?php echo danger_badge ($inv['stock_encontrado'], 'distinto', $inv['stock_sistema']); ?></span></td>
								
								<td class="text-center fecha-revision"><span class="tt" title="Fecha Revisión"><?php echo fechaHora($inv['created'], 1); ?></span></td>
								<td><span class="tt" title="Revisor"><?php echo $usuarios[$inv['id_revisor']]; ?></span></td>
							</tr>
						<?php
						}
						?>
					</tbody>
				</table>
			</div>
		</li>
		<?php
		}
	}
	else {
		?>
		<li class="list-group-item">
			<?php 
				echo 'No se encontraron inventarios realizados';
			?>
		</li>
		<?php
	}
	?>
</ul>
