Files
citrus-cms/app/Services/RegisterCreator/DocumentProcessors/NaksConsumablesCertificateProcessor.php
T
2026-04-28 21:14:25 +03:00

41 lines
1.4 KiB
PHP

<?php
namespace App\Services\RegisterCreator\DocumentProcessors;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class NaksConsumablesCertificateProcessor extends AbstractDocumentProcessor
{
public function process(array $weldLogData, array $document, Worksheet $sheet, int &$currentRow, array $settings): int
{
$this->initialize($weldLogData, $document, $sheet, $currentRow, $settings);
$certificates = array_filter([
$weldLogData['welding_materials_1_certificate_no'] ?? '',
$weldLogData['welding_materials_2_certificate_no'] ?? '',
$weldLogData['welding_materials_3_certificate_no'] ?? ''
]);
$placeholderReplacer = new \App\Services\RegisterCreator\PlaceholderReplacer();
foreach ($certificates as $certNo) {
$normalized = $this->normalizeSearchTerm($certNo);
$search = $this->searchFiles("storage/documents/{$document['path']}/*{$normalized}*.pdf");
$document['title2'] = $certNo;
$this->document = $document;
$documentDate = $placeholderReplacer->getLatestDate($weldLogData, $this->registerColumnBased);
$newRow = $this->addRowToExcel($search, $certNo, $documentDate);
if ($newRow > $currentRow) { $currentRow = $newRow; }
}
return $currentRow;
}
}