@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 ?? '') }}