<ul class="list-group">
	<li class="list-group-item header-right">
		<?php
			$data['a'] = 'ee';
			$this->load->view('ventas/navigation', $data);
		?>
	</li>
<?php
//$data['clientes'] = $clientes;
if(!empty($ventas)) {
	foreach($ventas as $k => $estado) {
		if(!empty($estado['id'])) {
			?>
			<li class="list-group-item ventas-estado-<?php echo $k;?>">
				<h4 class="mes clickable" data-toggle="collapse" href="#collapse<?php echo $k;?>"><?php echo $estado['nombre'];?>
					<span class="badge badge-pill badge-info tt" title="Cantidad de ventas"><?php echo (!empty($estado['ventas']) ? count($estado['ventas']) : 0);?></span>
					<span class="badge badge-pill badge-success tt" title="Total"><?php echo clp($estado['total']); ?></span>
					<a href="/productos/state/<?php echo $k; ?>" target="_blank"><span class="badge badge-pill badge-primary tt" title="Ver Productos"><i class="fas fa-box"></i></span></a>
				</h4>
				<div class="collapse processing" id="collapse<?php echo $k; ?>">
					<?php
					if (!empty($estado['ventas'])) {
						foreach($estado['ventas'] as $v) {
							//$data['v'] = $v;
							//$this->load->view('ventas/single', $data);
							if(!empty($v['asociados'])){
								echo '<div class="ventas-asociadas border rounded px-2 py-2 mb-1">';
							}
							if(!empty($v['ps_id_asociado'])){
								echo '<div class="venta-huerfana border rounded px-2 py-2 mb-1">';
							}
							$data['v'] = $v;
							$this->load->view('ventas/single', $data);
							if(!empty($v['ps_id_asociado'])){
								echo '</div>';
							}
							if(!empty($v['asociados'])){
								foreach($v['asociados'] as $va){
									$data['v'] = $va;
									$this->load->view('ventas/single', $data);
								}
								echo '</div>';
							}
						}
					}
					else {
						?>
						<div class="border rounded p-3 mb-1">No hay ventas en proceso</div>
						<?php
					}
					?>
				</div>
			</li>
			<?php
		}
	}
}
else {
	?>
	<li>A&uacute;n no hay ventas</li>
	<?php
}
?>
</ul>

<?php
	$this->load->view('ventas/modal');
?>
<script src="<?php echo js('ventas.js'); ?>"></script>