support for skipping default columns

This commit is contained in:
Uwe Steinmann 2025-02-14 08:22:12 +01:00
parent b75bcb5725
commit b2cc1a122e

View File

@ -93,6 +93,12 @@ class SeedDMS_Download_Mgr {
*/
protected $filenames;
/**
* @var boolean $skipdefaultcols skip default columns, will only export extracols
* @access protected
*/
protected $skipdefaultcols;
function __construct($tmpdir = '') {
$this->tmpdir = $tmpdir;
$this->items = array();
@ -105,8 +111,13 @@ class SeedDMS_Download_Mgr {
$this->extraheader = array();
$this->folder_extraheader = array();
$this->filenames = array();
$this->skipdefaultcols = false;
}
public function setSkipDefaultCols($v) { /* {{{ */
$this->skipdefaultcols = (bool) $v;
} /* }}} */
public function addHeader($extraheader) { /* {{{ */
$this->extraheader = $extraheader;
} /* }}} */
@ -137,8 +148,9 @@ class SeedDMS_Download_Mgr {
$i = 1;
$col = 1;
foreach($this->header as $h)
$sheet->setCellValue([$col++, $i], $h);
if(!$this->skipdefaultcols)
foreach($this->header as $h)
$sheet->setCellValue([$col++, $i], $h);
foreach($this->extraheader as $h)
$sheet->setCellValue([$col++, $i], $h);
$i++;
@ -151,13 +163,14 @@ class SeedDMS_Download_Mgr {
$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());
$l = $i;
$k = $i;
if($reviewStatus) {
foreach ($reviewStatus as $r) {
switch ($r["type"]) {
@ -181,7 +194,7 @@ class SeedDMS_Download_Mgr {
$tcol = $col;
$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->getStyleByColumnAndRow($tcol++, $l)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME);
$sheet->getStyle([$tcol++, $l])->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME);
$sheet->setCellValue([$tcol++, $l], $r['comment']);
$sheet->setCellValue([$tcol++, $l], getReviewStatusText($r["status"]));
$l++;
@ -212,7 +225,7 @@ class SeedDMS_Download_Mgr {
$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->getStyleByColumnAndRow($tcol++, $k)->getNumberFormat()->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_DATE_DATETIME);
$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++;
@ -220,6 +233,7 @@ class SeedDMS_Download_Mgr {
$k--;
}
$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 );
@ -239,8 +253,9 @@ class SeedDMS_Download_Mgr {
$i = 1;
$col = 1;
foreach($this->folder_header as $h)
$sheet->setCellValue([$col++, $i], $h);
if(!$this->skipdefaultcols)
foreach($this->folder_header as $h)
$sheet->setCellValue([$col++, $i], $h);
foreach($this->folder_extraheader as $h)
$sheet->setCellValue([$col++, $i], $h);
$i++;
@ -251,8 +266,10 @@ class SeedDMS_Download_Mgr {
$dms = $folder->_dms;
$col = 1;
$sheet->setCellValue([$col++, $i], $folder->getID());
$sheet->setCellValue([$col++, $i], $folder->getName());
if(!$this->skipdefaultcols) {
$sheet->setCellValue([$col++, $i], $folder->getID());
$sheet->setCellValue([$col++, $i], $folder->getName());
}
if(isset($this->folder_extracols[$item->getID()]) && $this->folder_extracols[$item->getID()]) {
foreach($this->folder_extracols[$item->getID()] as $column)
$sheet->setCellValue([$col++, $i], is_array($column) ? implode("\n", $column) : $column );