From 195574485b35acae907ca97f706a50ae31f77805 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 6 Mar 2026 21:27:40 +0100 Subject: [PATCH] add support for extra fields with multiple values --- inc/inc.ClassDownloadMgr.php | 48 ++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/inc/inc.ClassDownloadMgr.php b/inc/inc.ClassDownloadMgr.php index f49173d4c..034040b31 100644 --- a/inc/inc.ClassDownloadMgr.php +++ b/inc/inc.ClassDownloadMgr.php @@ -179,20 +179,20 @@ class SeedDMS_Download_Mgr { if($item->isType('documentcontent')) { $document = $item->getDocument(); $dms = $document->_dms; + + $col = 1; + $k = $i; // Number of approvers + if(!$this->skipdefaultcols) { $status = $item->getStatus(); $reviewStatus = $item->getReviewStatus(); $approvalStatus = $item->getApprovalStatus(); - - $col = 1; - $l = $i; // Number of reviewers - $k = $i; // Number of approvers - if(!$this->skipdefaultcols) { $sheet->setCellValue([$col++, $i], $document->getID()); $sheet->setCellValue([$col++, $i], $document->getName()); $sheet->setCellValue([$col++, $i], $document->getID()."-".$item->getOriginalFileName()); $sheet->setCellValue([$col++, $i], getOverallStatusText($status['status'])); $sheet->setCellValue([$col++, $i], $item->getVersion()); if($reviewStatus) { + $l = $i; foreach ($reviewStatus as $r) { switch ($r["type"]) { case 0: // Reviewer is an individual. @@ -221,9 +221,11 @@ class SeedDMS_Download_Mgr { $l++; } $l--; + $k = max($k, $l); } $col += 4; if($approvalStatus) { + $l = $i; foreach ($approvalStatus as $r) { switch ($r["type"]) { case 0: // Reviewer is an individual. @@ -244,23 +246,37 @@ class SeedDMS_Download_Mgr { break; } $tcol = $col; - $sheet->setCellValue([$tcol++, $k], $reqName); - $sheet->setCellValue([$tcol, $k], ($r['status']==1 || $r['status']==-1) ? \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(new DateTime($r['date'])) : null); - $sheet->getStyle([$tcol++, $k])->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME); - $sheet->setCellValue([$tcol++, $k], $r['comment']); - $sheet->setCellValue([$tcol++, $k], getApprovalStatusText($r["status"])); - $k++; + $sheet->setCellValue([$tcol++, $l], $reqName); + $sheet->setCellValue([$tcol, $l], ($r['status']==1 || $r['status']==-1) ? \PhpOffice\PhpSpreadsheet\Shared\Date::PHPToExcel(new DateTime($r['date'])) : null); + $sheet->getStyle([$tcol++, $l])->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME); + $sheet->setCellValue([$tcol++, $l], $r['comment']); + $sheet->setCellValue([$tcol++, $l], getApprovalStatusText($r["status"])); + $l++; } - $k--; + $l--; + $k = max($k, $l); } $col += 4; } if(isset($this->extracols[$item->getID()]) && $this->extracols[$item->getID()]) { - foreach($this->extracols[$item->getID()] as $column) - $sheet->setCellValue([$col++, $i], is_array($column) ? implode("\n", $column) : $column ); + foreach($this->extracols[$item->getID()] as $column) { + $l = $i; + if (is_array($column)) { + if ($column) { + foreach ($column as $cl) { + $sheet->setCellValue([$col, $l++], $cl); + } + } else { + $sheet->setCellValue([$col, $i], ''); + } + $col++; + } else { + $sheet->setCellValue([$col++, $i], $column); + } + } } - $i = max($l, $k); - $i++; + $k = max($k, $l); + $i = $k+1; } } }