<?php
$checked = '';
$class = '';
if ($c['revisado']) {
	$checked = 'checked="checked"';
	$class = 'compra-revisada';
}
?>
<div class="card card-body mb-1 compra <?php echo $class; ?>" id="compra<?php echo $c['id']; ?>">
	<div class="row">
		<div class="col-12 col-md-6">
			<span class="folio badge badge-pill badge-primary tt" title="Nro de folio"><?php echo !empty($c['folio']) ? $c['folio'] : '0'; ?></span>
			<span class="nombre">
				<?php echo (!empty($c['id_proveedor']) ? '<a target="_blank" href="/proveedores/view/' . $c['id_proveedor'] . '">' . $proveedores[$c['id_proveedor']] . '</a>' : 'Sin Proveedor asociado'); ?>
			</span>
		</div>
		
		<div class="col-6 col-md-3">
			<span class="badge badge-pill badge-primary tt" title="Fecha de recepción"><?php echo fecha($c['fecha_recepcion']); ?></span>
		</div>
		
		<div class="col-6 col-md-3 text-right">
			<?php
				$idCategoria = $c['id_categoria'] ?? 0;
				$categoria = $categorias_compras[$idCategoria] ?? '';
			?>

			<span class="badge badge-pill badge-info tt" title="Categoría de compra"><?php echo $categoria; ?></span>
			<span class="badge badge-pill badge-primary tt" title="Tipo de compra"><?php echo $tipos_compras[$c['id_tipo_compra']]; ?></span>
			<button type="button" class="btn btn-primary btn-xs" data-toggle="modal" data-target="#modalCompra" data-id="<?php echo $c['id']; ?>">
				<i class="fas fa-pencil-alt"></i>
			</button>
			<?php if (in_array($_SESSION['usuario']['perfil'], [1,2])) { ?>
				<input type="checkbox" name="revisado" class="check-revisado big-check" value="1" data-id ="<?php echo $c['id']; ?>" <?php echo $checked; ?>/>
			<?php } ?>
		</div>
		
	</div>
	<div class="row">
		<div class="col-0 col-md-6 texto-observaciones">
			<strong><?php echo $c['observaciones']?></strong>
		</div>
		<div class="col-4 col-md-2 neto">
			<span class="tt" title="Monto Neto"><?php echo clp($c['total_neto']); ?></span>
		</div>
		<div class="col-4 col-md-2  text-center iva ">
			<span class="tt" title="Monto IVA"><?php echo clp($c['iva']); ?></span>
		</div>
		<div class="col-4 col-md-2  text-right total">
			<span class="tt" title="Monto Total"><?php echo clp($c['total']); ?></span>
		</div>
	</div>
</div>