@isset($exportar) @php header("Cache-Control: maxage=1"); header("Pragma: public"); header('Content-type: application/vnd.ms-excel'); header("Content-Disposition: attachment; filename=Cumplimiento.xls"); header("Pragma: no-cache"); header("Expires: 0"); @endphp @endisset @php $totVenta = 0; $totPresupuesto = 0; $totVentaConPresupuesto = 0; $isExport = isset($exportar); @endphp
@if($Tipo == "vendedor") @if($Agrupado == "detallado") @else @endif @else @if($Agrupado == "detallado") @else @endif @endif @isset($productos) @foreach ($productos as $item) @php $valVenta = floatval($item["valor"] ?? 0); $valPresup = floatval($item["valorPresup"] ?? 0); $diferencia = $valVenta - $valPresup; $totVenta += $valVenta; $totPresupuesto += $valPresup; $hasPresupuesto = ($valPresup > 0); if ($hasPresupuesto) { $totVentaConPresupuesto += $valVenta; $pct = round(($valVenta / $valPresup) * 100, 1); } else { $pct = 0; } // Clases dinámicas de color para % de cumplimiento if (!$hasPresupuesto) { $badgeClass = 'bg-secondary text-white'; $progressClass = 'bg-secondary'; } elseif ($pct >= 100) { $badgeClass = 'bg-success text-white'; $progressClass = 'bg-success'; } elseif ($pct >= 80) { $badgeClass = 'bg-warning text-dark'; $progressClass = 'bg-warning'; } else { $badgeClass = 'bg-danger text-white'; $progressClass = 'bg-danger'; } $code = ($Tipo == "vendedor") ? ($item["codigoVendedor"] ?? '') : ($item["bodega"] ?? ''); $name = ($Tipo == "vendedor") ? ($item["nombrev"] ?? '') : ($item["nombreB"] ?? ''); @endphp @if($Agrupado == "detallado") @endif @endforeach @endisset @isset($productos) @if(count($productos) > 0) @php $totDiferencia = $totVenta - $totPresupuesto; $hasTotPresupuesto = ($totPresupuesto > 0); // Se calcula el % sobre las ventas que sí tenían presupuesto configurado $totPct = $hasTotPresupuesto ? round(($totVentaConPresupuesto / $totPresupuesto) * 100, 1) : 0; if (!$hasTotPresupuesto) { $totBadge = 'bg-secondary text-white'; } elseif ($totPct >= 100) { $totBadge = 'bg-success text-white'; } elseif ($totPct >= 80) { $totBadge = 'bg-warning text-dark'; } else { $totBadge = 'bg-danger text-white'; } @endphp @if($Agrupado == "detallado") @endif @endif @endisset
Cód. Vend Vendedor Venta Real ($) Presupuesto ($) Diferencia ($) % Cumplimiento Día Mes Año
Cód. Vend Vendedor Venta Real ($) Presupuesto ($) Diferencia ($) % Cumplimiento
Cód. Bodega Bodega Venta Real ($) Presupuesto ($) Diferencia ($) % Cumplimiento Día Mes Año
Cód. Bodega Bodega Venta Real ($) Presupuesto ($) Diferencia ($) % Cumplimiento
{{ $code }} {{ $name }} ${{ number_format($valVenta, 0) }} ${{ number_format($valPresup, 0) }} ${{ number_format($diferencia, 0) }} @if($isExport) {{ $hasPresupuesto ? number_format($pct, 1) . '%' : 'N/A' }} @else @if($hasPresupuesto)
{{ $pct > 999 ? '>999%' : number_format($pct, 1) . '%' }}
@else N/A @endif @endif
{{ $item["diaV"] ?? '' }} {{ $item["mesV"] ?? '' }} {{ $item["ageV"] ?? '' }}
Totales Generales: ${{ number_format($totVenta, 0) }} ${{ number_format($totPresupuesto, 0) }} ${{ number_format($totDiferencia, 0) }} @if($isExport) {{ $hasTotPresupuesto ? ($totPct > 999 ? '>999%' : number_format($totPct, 1) . '%') : 'N/A' }} @else @if($hasTotPresupuesto) {{ $totPct > 999 ? '>999%' : number_format($totPct, 1) . '%' }} @else N/A @endif @endif