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

58 lines
2.5 KiB
PHP

<?php
namespace App\Services\TpCreator\DocumentProcessors;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
class QaProcessor extends AbstractTpDocumentProcessor
{
public function process(array $lineData, array $document, Worksheet $sheet, int $currentRow, array $settings): int
{
$testPackageNo = $lineData['test_package_number'];
$docPath = $document['path'];
$override = $settings['override'] ?? true;
$folder = $settings['full_folder'];
$rowNo = $settings['row_no'];
$allJoints = db("weld_logs")->where("test_package_no", $testPackageNo)->get();
$logTypes = array_keys(log_test_types());
foreach($allJoints as $joint) {
$jointArray = (array)$joint;
foreach($logTypes as $logType) {
if (strpos(strtolower($docPath), $logType) !== false) {
$reportNoPrefix = ($logType == "pmi") ? "no_of_testing_report" : $logType . "_report";
if (!empty($jointArray[$reportNoPrefix])) {
$reportNo = $jointArray[$reportNoPrefix];
$docDate = $jointArray[$logType . '_test_date'];
$search = $this->alternativeGlob("storage/documents/{$docPath}/{$reportNo}.pdf");
$document['title2'] = $reportNo;
// Translation
$translationKey = $logType . "_register_title";
// Note: If using helper e2(), ensure it's available or pass via settings.
// Assuming e2 is global helper.
$document['title4'] = e2($translationKey);
$this->addRow($search, $document, $folder, $reportNo, $docDate, $rowNo, $sheet, $currentRow, $override);
}
}
}
}
// Update row_no in settings passed by reference if needed, but simple return of new currentRow is standard.
// However, we also need to return new rowNo count or just the new currentRow index.
// The Abstract class addRow increments currentRow and rowNo by reference.
// But since rowNo is primitive, it won't persist back to caller unless we return it or use object.
// TpCreatorService expects new currentRow.
// We actually need to return how many rows added or the new current Row.
return $currentRow;
}
}