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

53 lines
1.3 KiB
PHP

<?php
namespace App\Services\RegisterCreator\DocumentProcessors;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
/**
* Generic processor for document types that don't have specific processors
*/
class GenericDocumentProcessor extends AbstractDocumentProcessor
{
/**
* Process generic document
*/
public function process(
array $weldLogData,
array $document,
Worksheet $sheet,
int &$currentRow,
array $settings
): int {
$this->initialize($weldLogData, $document, $sheet, $currentRow, $settings);
$this->log("Processing generic document: {$document['type']}");
$lineIdentifier = $weldLogData[$this->registerColumnBased];
$normalized = $this->normalizeSearchTerm($lineIdentifier);
$search = $this->searchFiles("storage/documents/{$document['path']}/*{$normalized}*.pdf");
$placeholderReplacer = new \App\Services\RegisterCreator\PlaceholderReplacer();
$documentDate = $placeholderReplacer->getLatestDate($weldLogData, $this->registerColumnBased);
$newRow = $this->addRowToExcel(
$search,
$lineIdentifier,
$documentDate
);
if ($newRow > $currentRow) {
$currentRow = $newRow;
}
return $currentRow;
}
}