41 lines
1.4 KiB
PHP
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;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|