<table class="table table-striped">
	<thead>
		<tr>
			<?php
				foreach ($cabeceras as $key => $c) {
					if ($key == 'marketplaces') {
						foreach ($marketplaces_detalles as $mp) {
							echo '<th scope="col" class="text-center">Stock ' . $mp['abreviacion'] . '</th>';
						}
					}
					else {
						echo '<th scope="col" class="' . $c['class'] . '">' . $c['nombre'] . '</th>';
					}
				}
			?>
		</tr>
	</thead>
	<tbody>
		<?php
		foreach($filas as $p) {
			?>
			<tr>
				<?php
				foreach ($cabeceras as $key => $c) {
					switch ($key) {
						case 'ps_id':
							$content = '<td class="' . $c['class'] . '">';
							$content .= '<span class="badge badge-pill badge-primary ps-id-product ver-ps" data-ps-id="' . $p['ps_id'] . '">';
							$content .= $p['ps_id'] . '</span></td>';
							break;

						case 'nombre':
							$content = '<td class="' . $c['class'] . '">';
							if (!empty($ps_imagenes[$p['ps_id']])) {
								$content .= ps_image($ps_imagenes[$p['ps_id']]);
							} 
							else if(!empty($p['ps_image_id'])) {
								$content .= ps_image($p['ps_image_id']);
							}
							$content .= '<a target="_blank" href="/productos/detalle/'. $p['id'] .'">';
							$content .= '<span class="nombre">' . $p['nombre'] . '</span></a></td>';
							break;

						case 'acciones':
							$content = '<td class="' . $c['class'] . '">';
							$content .= '<button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#modalProducto" data-id="' . $p['id'] . '">';
							$content .= '<i class="fas fa-pencil-alt"></i></button></td>';
							break;

						case 'marketplaces':
							$content = '';
							foreach ($marketplaces as $key => $mp) {
								$content .= '<td class="text-center">';
								if (!empty($p['marketplaces'][$key]['activo'])) {
									$content .= $p['marketplaces'][$key]['stock'];
								}
								$content .= '</td>';
							}
							break;

						default: 
							$content = '<td class="' . $c['class'] . '">';
							if (!empty($c['type']) && $c['type'] == 'fecha') {
								$content .= fecha($p[$key]);
							}
							else {
								$content .= $p[$key];
							}
							$content .= '</td>';
							break;
					}

					echo $content;
				}
				?>
			</tr>
		<?php
		}
		?>
	</tbody>
</table>