| Número de Venta: | {{ $venta->id }} | Estado: | {{ $venta->estado }} |
| Fecha de Creación: | {{ $venta->fecha ? $venta->fecha->format('d/m/Y') : 'No definida' }} | Fecha de Aprobación: | {{ $venta->fecha_aprobacion ? $venta->fecha_aprobacion->format('d/m/Y') : 'Pendiente' }} |
| Contacto: | {{ $venta->nombre ?: 'Sin nombre' }} | Email: | {{ $venta->email ?: 'No definido' }} |
| Fecha de Entrega: | {{ $venta->fecha_entrega ? $venta->fecha_entrega->format('d/m/Y') : 'No definida' }} | Teléfono: | {{ $venta->telefono ?: 'No definido' }} |
| Imagen | Cant. | Producto | Prov. Producto | Prov. Aplicación | Valores |
|---|---|---|---|---|---|
|
@php
$imagenBase64 = null;
// Intentar con imágenes del producto primero
if($ventaProducto->producto && $ventaProducto->producto->images) {
$images = is_string($ventaProducto->producto->images) ? json_decode($ventaProducto->producto->images, true) : $ventaProducto->producto->images;
$firstImage = is_array($images) && !empty($images) ? $images[0] : null;
if($firstImage) {
// Verificar si es una URL remota
if(filter_var($firstImage, FILTER_VALIDATE_URL)) {
try {
$imagenData = @file_get_contents($firstImage);
if($imagenData !== false) {
$imagenBase64Data = base64_encode($imagenData);
$extension = strtolower(pathinfo(parse_url($firstImage, PHP_URL_PATH), PATHINFO_EXTENSION));
$mimeType = $extension === 'png' ? 'png' : ($extension === 'webp' ? 'webp' : 'jpeg');
$imagenBase64 = "data:image/$mimeType;base64," . $imagenBase64Data;
}
} catch (\Exception $e) {
// Silenciosamente ignorar errores de descarga
}
} else {
// Es una ruta local
$rutaImagen = storage_path('app/public/' . $firstImage);
if(file_exists($rutaImagen)) {
$imagenData = base64_encode(file_get_contents($rutaImagen));
$extension = strtolower(pathinfo($rutaImagen, PATHINFO_EXTENSION));
$mimeType = $extension === 'png' ? 'png' : ($extension === 'webp' ? 'webp' : 'jpeg');
$imagenBase64 = "data:image/$mimeType;base64," . $imagenData;
}
}
}
}
// Si no hay imagen del producto, intentar con maqueta_imagen
if(!$imagenBase64 && $ventaProducto->maqueta_imagen) {
$rutaImagen = storage_path('app/public/' . $ventaProducto->maqueta_imagen);
if(file_exists($rutaImagen)) {
$imagenData = base64_encode(file_get_contents($rutaImagen));
$extension = strtolower(pathinfo($rutaImagen, PATHINFO_EXTENSION));
$mimeType = $extension === 'png' ? 'png' : ($extension === 'webp' ? 'webp' : 'jpeg');
$imagenBase64 = "data:image/$mimeType;base64," . $imagenData;
}
}
@endphp
@if($imagenBase64)
Sin imagen
@endif
|
{{ $cantidad }} |
{{ $ventaProducto->producto->name ?? 'Producto no encontrado' }}
{{ $codigo }}
|
@if($ventaProducto->isAgotado())
—
@else
@if($ventaProducto->proveedor_producto)
{{ $ventaProducto->proveedorProducto->name ?? 'Proveedor ' . $ventaProducto->proveedor_producto }}
@endif
@if($precioProveedor > 0)
${{ number_format($precioProveedor, 0, ',', '.') }}
@endif
@endif
|
@if($ventaProducto->isAgotado())
—
@else
@if($ventaProducto->tiene_aplicacion && $ventaProducto->proveedor_aplicacion)
{{ $ventaProducto->proveedorAplicacion->name ?? 'Proveedor ' . $ventaProducto->proveedor_aplicacion }}
@if($ventaProducto->tipo_aplicacion && $ventaProducto->tipo_aplicacion !== 'Sin Aplicación')
{{ $ventaProducto->tipo_aplicacion }}
@endif
@if($valorEstimado > 0)
${{ number_format($valorEstimado, 0, ',', '.') }}
@endif
@else
Sin aplicación
@endif
@endif
|
@if($ventaProducto->isAgotado())
Producto Agotado
@else
Unidad: ${{ number_format($valorUnitarioConAgencia, 0, ',', '.') }}
Total: ${{ number_format($valorTotal, 0, ',', '.') }}
Util: ${{ number_format($utilidadTotal, 0, ',', '.') }} ({{ $utilidad }}%)
@endif
|
No hay productos asociados a esta venta.
@endif @if($venta->nota)