<div class="modal fade" id="modalStockAlmacenes" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="editStockAlmacenesLabel" aria-hidden="true">
	<div class="modal-dialog modal-xl" role="document">
		<div class="modal-content">
			<div class="modal-wait">
				<div class="modal-header">
					<h5 class="modal-title" id="editStockAlmacenesLabel">Editar Stocks</h5>
					<button type="button" class="close" data-dismiss="modal" aria-label="Close">
						<span aria-hidden="true">&times;</span>
					</button>
				</div>
				<div class="modal-body">
					<h3>
						Stock en Tiendas
					</h3>
					<form id="formStockProducto" action="/productos/save_stock" method="post">
						<input type="hidden" name="id" id="idProducto" value="0" />
						<div class="table-responsive">
							<table class="table">
								<tr>
									<th>Almacén</th>
									<th>Ubicación</th>
									<th class="text-center"><span class="d-none d-md-inline">Disponibles</span><span class="d-md-none">Disp</span></th>
									<th class="text-center"><span class="d-none d-md-inline">Reservados</span><span class="d-md-none">Res</span></th>
									<th class="text-center">Stock Físico</th>
									<?php /*<th>Sugeridos</th> */ ?>
									<th class="text-center">Deseado Min</th>
									<th class="text-center">Deseados Max</th>
								</tr>
							<?php 

							foreach ($almacenes_listado['tiendas'] as $idAlmacen => $almacen) {
							?>
								<tr>
									<td><?php echo $almacen; ?></td>
									<td>
										<select name="id_ubicacion[<?php echo $idAlmacen; ?>]" class="form-control id-ubicacion-<?php echo $idAlmacen; ?>">
											<option value="0">Sin Ubicación Asignada</option>
											<?php 
											if (!empty($ubicaciones[$idAlmacen])) {
												foreach($ubicaciones[$idAlmacen] as $k => $v) {
													echo '<option value="'.$k.'">'.$v.'</option>';
												}
											}
											?>
										</select>
									</td>
									<td id="disponibles-<?php echo $idAlmacen; ?>" class="text-center"><span class="badge badge-pill badge-success disponibles">0</span></td>
									<td id="reservados-<?php echo $idAlmacen; ?>" class="text-center"><span class="badge badge-pill badge-warning reservados">0</span></td>
									<td id="stock-<?php echo $idAlmacen; ?>" class="text-center">
										<?php
										if (in_array($_SESSION['usuario']['perfil'], [1, 2])) {
											?>
											<input type="number" name="stock_almacen[<?php echo $idAlmacen; ?>]" class="form-control input-stock-almacen" data-id="<?php echo $idAlmacen; ?>" placeholder="Stock <?php echo $almacen; ?>">
											<?php
										}
										else {
											?>
											<span class="badge badge-pill badge-info stock">0</span>
											<?php
										}
										?>
										</td>
									<td id="deseados-<?php echo $idAlmacen; ?>" class="text-center">
										<input type="number" name="deseados_almacen[<?php echo $idAlmacen; ?>]" class="form-control input-deseados-almacen" data-id="<?php echo $idAlmacen; ?>">
									</td>
									<td id="deseados-max-<?php echo $idAlmacen; ?>" class="text-center">
										<input type="number" name="deseados_max_almacen[<?php echo $idAlmacen; ?>]" class="form-control input-deseados-max-almacen" data-id="<?php echo $idAlmacen; ?>">
									</td>
								</tr>

							<?php
							}
							?>
							<tr><td colspan="7"><h5>Otros almacenes</h5></td></tr>

							<?php
							foreach ($almacenes_listado['otros'] as $idAlmacen => $almacen) {
							?>
								<tr>
									<td><?php echo $almacen; ?></td>
									<td>
										<select name="id_ubicacion[<?php echo $idAlmacen; ?>]" class="form-control id-ubicacion-<?php echo $idAlmacen; ?>">
											<option value="0">Sin Ubicación Asignada</option>
											<?php 
											if (!empty($ubicaciones[$idAlmacen])) {
												foreach($ubicaciones[$idAlmacen] as $k => $v) {
													echo '<option value="'.$k.'">'.$v.'</option>';
												}
											}
											?>
										</select>
									</td>
									<td id="disponibles-<?php echo $idAlmacen; ?>" class="text-center"><span class="badge badge-pill badge-success disponibles">0</span></td>
									<td id="reservados-<?php echo $idAlmacen; ?>" class="text-center"><span class="badge badge-pill badge-warning reservados">0</span></td>
									<td id="stock-<?php echo $idAlmacen; ?>" class="text-center">
										<?php
										if (in_array($_SESSION['usuario']['perfil'], [1, 2])) {
											?>
											<input type="number" name="stock_almacen[<?php echo $idAlmacen; ?>]" class="form-control input-stock-almacen" data-id="<?php echo $idAlmacen; ?>" placeholder="Stock <?php echo $almacen; ?>">
											<?php
										}
										else {
											?>
											<span class="badge badge-pill badge-info stock">0</span>
											<?php
										}
										?>
										</td>
									<td id="deseados-<?php echo $idAlmacen; ?>" class="text-center">
										<input type="number" name="deseados_almacen[<?php echo $idAlmacen; ?>]" class="form-control input-deseados-almacen" data-id="<?php echo $idAlmacen; ?>">
									</td>
									<td id="deseados-max-<?php echo $idAlmacen; ?>" class="text-center">
										<input type="number" name="deseados_max_almacen[<?php echo $idAlmacen; ?>]" class="form-control input-deseados-max-almacen" data-id="<?php echo $idAlmacen; ?>">
									</td>
								</tr>

							<?php
							}
							?>
							</table>
						</div>
					</form>
				</div>
				<div class="modal-footer">
					<button type="button" class="btn btn-secondary" data-dismiss="modal">Cerrar</button>
					<button type="button" class="btn btn-primary" id="editarStock">Editar</button>
				</div>
			</div>
		</div>
	</div>
</div>
