@php $buscarFuente = function (array $rutas) { foreach ($rutas as $ruta) { if ($ruta && file_exists($ruta) && !is_dir($ruta)) { return str_replace('\\', '/', $ruta); } } return null; }; $rutaFuenteCss = function ($ruta) { if (!$ruta) { return null; } if (preg_match('/^[A-Za-z]:\//', $ruta)) { return 'file:///'.$ruta; } if (strpos($ruta, '/') === 0) { return 'file://'.$ruta; } return $ruta; }; $arial_regular_path = $buscarFuente(array( public_path('assets/fonts/arial.ttf'), public_path('assets/fonts/Arial.ttf'), storage_path('fonts/arial.ttf'), storage_path('fonts/Arial.ttf'), 'C:/Windows/Fonts/arial.ttf', '/usr/share/fonts/truetype/msttcorefonts/arial.ttf', '/usr/share/fonts/truetype/msttcorefonts/Arial.ttf', '/usr/share/fonts/truetype/microsoft/arial.ttf', '/usr/share/fonts/truetype/microsoft/Arial.ttf', )); $arial_bold_path = $buscarFuente(array( public_path('assets/fonts/arialbd.ttf'), public_path('assets/fonts/Arial-Bold.ttf'), public_path('assets/fonts/Arial_Bold.ttf'), storage_path('fonts/arialbd.ttf'), storage_path('fonts/Arial-Bold.ttf'), storage_path('fonts/Arial_Bold.ttf'), 'C:/Windows/Fonts/arialbd.ttf', '/usr/share/fonts/truetype/msttcorefonts/arialbd.ttf', '/usr/share/fonts/truetype/msttcorefonts/Arial_Bold.ttf', '/usr/share/fonts/truetype/microsoft/arialbd.ttf', '/usr/share/fonts/truetype/microsoft/Arial_Bold.ttf', )); @endphp @php $texto = function ($valor, $default = '---') { $valor = trim((string) $valor); return $valor !== '' ? $valor : $default; }; $fecha = function ($valor, $default = '---') { $valor = trim((string) $valor); return $valor !== '' ? formatDateForDisplay($valor) : $default; }; $upper = function ($valor) { $valor = trim((string) $valor); return function_exists('mb_strtoupper') ? mb_strtoupper($valor, 'UTF-8') : strtoupper($valor); }; $moneda = $texto($datos_reporte->tipo_moneda ?? 'MXN', 'MXN'); $logo_seatsa = trim((string) ($datos_documento_version->logo_seatsa ?? '')); $logo_seatsa = $logo_seatsa !== '' ? $logo_seatsa : 'seatsa_jpgs-01.jpg'; $logo_seatsa_path = public_path('assets/images/'.$logo_seatsa); if (!file_exists($logo_seatsa_path) || is_dir($logo_seatsa_path)) { $logo_seatsa_path = public_path('assets/images/seatsa_jpgs-01.jpg'); } $firmaPath = function ($firma) { if (!$firma || (int) ($firma->estatus_firma ?? 0) !== 1) { return null; } $archivo = trim((string) ($firma->firma_digital ?? '')); if ($archivo === '') { return null; } $path = storage_path('app/public/archivos_usuario/'.$archivo); return (file_exists($path) && !is_dir($path)) ? $path : null; }; $nombreFirma = function ($firma, $default) use ($texto) { if (!$firma) { return $default; } $nombre = trim((string) ($firma->nombre ?? '').' '.(string) ($firma->apellidos ?? '')); return $texto($nombre, $default); }; $nombre_solicitante = trim( (string) ($datos_solicitante->nombre ?? '') . ' ' . (string) ($datos_solicitante->apellidos ?? '') ); $area_negocio = $datos_unidad_negocio ? $datos_unidad_negocio->nombre_unidad_negocio : ''; $area_linea = $datos_linea_trabajo ? $datos_linea_trabajo->linea_trabajo : ''; $producto_servicio = $datos_seccion_1 ? $datos_seccion_1->servicio_producto : ''; if ($datos_seccion_1 && trim((string) $datos_seccion_1->servicio_producto_otro) !== '') { $producto_servicio = $datos_seccion_1->servicio_producto_otro; } $subtotal = isset($datos_reporte->subtotal_seccion2) && $datos_reporte->subtotal_seccion2 !== null ? (float) $datos_reporte->subtotal_seccion2 : 0; if ($subtotal <= 0 && $datos_conceptos) { foreach ($datos_conceptos as $concepto) { $subtotal += ((float) $concepto->cantidad) * ((float) $concepto->precio); } } $iva = isset($datos_reporte->monto_iva) && $datos_reporte->monto_iva !== null ? (float) $datos_reporte->monto_iva : 0; if ($iva <= 0 && (int) ($datos_reporte->aplica_iva ?? 1) === 1) { $iva = $subtotal * (((float) ($datos_reporte->porcentaje_iva ?? 16)) / 100); } $total = isset($datos_reporte->total_seccion2) && $datos_reporte->total_seccion2 !== null ? (float) $datos_reporte->total_seccion2 : ($subtotal + $iva); $estatus_aprobacion = 'PENDIENTE'; if ((int) ($datos_reporte->estatus ?? 1) === 2) { $estatus_aprobacion = 'APROBADO'; } elseif ((int) ($datos_reporte->estatus ?? 1) === 0) { $estatus_aprobacion = 'NO APROBADO'; } $entregas = isset($parcialidades_entrega) ? $parcialidades_entrega : collect(); $pagos = isset($formatos_pago) ? $formatos_pago : array(); $total_pagos = count($pagos); $total_entregas = $entregas->count(); $firma_area_tecnica_path = $firmaPath($firma_area_tecnica); $firma_area_administrativa_path = $firmaPath($firma_area_administrativa); $firma_inspeccion_path = $firmaPath($firma_inspeccion); $firma_conclusion_path = $firmaPath($firma_conclusion); @endphp
FOLIO DE REQUISICIÓN: {{ $id_requisicion_reporte }}
REQUISICIÓN DE COMPRA
FECHA DE SOLICITUD: {{ $fecha($datos_reporte->fecha ?? '') }}
ÁREA DE NEGOCIO: {{ $texto($area_negocio) }}
NOMBRE DEL SOLICITANTE: {{ $texto($nombre_solicitante) }}
ÁREA: {{ $texto($area_linea, 'SIN LÍNEA DE TRABAJO ASIGNADA') }}
CARÁCTER: {{ $texto($datos_reporte->caracter ?? '') }}
1. TIPO DE SUMINISTRO Y PRODUCTO {{ $texto($datos_seccion_1->tipo_servicio_suministro ?? '') }}
PRODUCTO/SERVICIO {{ $texto($producto_servicio) }}
2. ESPECIFICACIONES
@if($datos_conceptos && $datos_conceptos->count() > 0) @foreach($datos_conceptos as $concepto) @endforeach @else @endif
CANTIDAD / UNIDAD NOMBRE DEL PRODUCTO / SERVICIO PRECIO
{{ $texto($concepto->cantidad ?? '') }} {{ $texto($concepto->nombre ?? '') }} $ {{ number_format((float) ($concepto->precio ?? 0), 2, '.', ',') }}
       
SUBTOTAL: $ {{ number_format($subtotal, 2, '.', ',') }}
IVA: $ {{ number_format($iva, 2, '.', ',') }}
TOTAL: $ {{ number_format($total, 2, '.', ',') }} {{ $moneda }}
2.1 DATOS DEL PROVEEDOR
NOMBRE DE EMPRESA {{ $texto($datos_seccion_2_1->empresa ?? '') }}
NOMBRE DE CONTACTO {{ $texto($datos_seccion_2_1->contacto ?? '') }}
CORREO (OPCIONAL) {{ $texto($datos_seccion_2_1->correo ?? '') }}
TELÉFONO (OPCIONAL) {{ $texto($datos_seccion_2_1->telefono ?? '') }}
DATOS BANCARIOS {{ $texto($datos_seccion_2_1->datos_bancarios ?? '') }}
@if($total_entregas > 0) @foreach($entregas as $entrega) @endforeach @else @endif @if($tiene_formatos_pago) @foreach($pagos as $pago) @php $pago_confirmado = isset($pago['pago_confirmado']) && $pago['pago_confirmado']; $monto_real = $pago_confirmado ? ($moneda.' $'.number_format((float) ($pago['monto_pago'] ?? 0), 2, '.', ',')) : '-'; $fecha_real = $pago_confirmado ? $fecha($pago['fecha_pago_realizado'] ?? '', '-') : '-'; @endphp @endforeach @endif
2.2 CÓMO SE RECIBE EL SUMINISTRO Y FORMAS DE PAGO
SUMINISTRO {{ $texto($datos_reporte->suministro ?? '') }} CANTIDAD DE PARCIALIDADES @if($total_entregas > 0) {{ $total_entregas }} @else {{ $texto($datos_reporte->suministro_parcialidad ?? '') }} @endif
{{ $loop->first ? 'FECHA DE ENTREGA PROGRAMADA' : '' }} {{ $fecha($entrega->fecha ?? '') }}
FECHA DE ENTREGA PROGRAMADA {{ $fecha($datos_reporte->fecha_entrega_programada ?? '') }}
FORMA DE PAGO {{ $texto($datos_reporte->forma_pago ?? '') }} CANTIDAD DE PARCIALIDADES @if($total_pagos > 0) {{ $total_pagos }} @elseif(trim((string) ($datos_reporte->fecha_pago ?? '')) !== '') 1 @else --- @endif
FECHA PARA REALIZAR
PAGO
@if($total_pagos > 0) @foreach($pagos as $pago) {{ $fecha($pago['fecha_programada_pago'] ?? '') }}@if(!$loop->last)
@endif @endforeach @else {{ $fecha($datos_reporte->fecha_pago ?? '') }} @endif
DETALLE DE PAGOS REALIZADOS
PAGO {{ $pago['numero_pago'] ?? $loop->iteration }} DE {{ $pago['total_pagos'] ?? $total_pagos }} FECHA PROGRAMADA: {{ $fecha($pago['fecha_programada_pago'] ?? '') }} FECHA REAL: {{ $fecha_real }} MONTO: {{ $monto_real }}
2.3 APROBACIÓN
ESTATUS DE APROBACIÓN: {{ $estatus_aprobacion }}
@if($firma_area_tecnica_path) @endif @if($firma_area_administrativa_path) @endif
FIRMA DE RESPONSABLE DE ÁREA
{{ $upper($nombreFirma($firma_area_tecnica, 'NOMBRE COMPLETO')) }}
FIRMA DE APROBACIÓN
{{ $upper($nombreFirma($firma_area_administrativa, 'NOMBRE COMPLETO')) }}
3. INSPECCIÓN O REVISIÓN DEL PRODUCTO O SERVICIO CONTRA ESPECIFICACIÓN
CRITERIO {{ $texto($datos_seccion_3->estatus_inspeccion ?? '') }}
¿POR QUÉ? {{ $texto($datos_seccion_3->porque ?? '') }}
OBSERVACIÓN {{ $texto($datos_seccion_3->observaciones ?? '') }}
INDICACIONES DE ALMACENAMIENTO (OPCIONAL) {{ $texto($datos_seccion_3->condiciones_almacenamiento ?? '') }}
@if($firma_inspeccion_path) @endif @if($firma_conclusion_path) @endif
FIRMA DE QUIEN REALIZÓ INSPECCIÓN
{{ $upper($nombreFirma($firma_inspeccion, 'NOMBRE COMPLETO')) }}
FIRMA REVISÓ CONCLUSIÓN DE COMPRA
{{ $upper($nombreFirma($firma_conclusion, 'NOMBRE COMPLETO')) }}