createToc() uses self::items, use counter for columns

This commit is contained in:
Uwe Steinmann 2015-06-17 07:59:06 +02:00
parent 5b03c3dcc3
commit 5d5d954077

View File

@ -48,24 +48,27 @@ class SeedDMS_Download_Mgr {
$this->items[$item->getID()] = $item; $this->items[$item->getID()] = $item;
} /* }}} */ } /* }}} */
public function createToc($file, $items) { /* {{{ */ public function createToc($file) { /* {{{ */
$items = $this->items;
$objPHPExcel = new PHPExcel(); $objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("SeedDMS")->setTitle("Metadata"); $objPHPExcel->getProperties()->setCreator("SeedDMS")->setTitle("Metadata");
$sheet = $objPHPExcel->setActiveSheetIndex(0); $sheet = $objPHPExcel->setActiveSheetIndex(0);
$i = 1; $i = 1;
$sheet->setCellValueByColumnAndRow(0, $i, 'Dokumenten-Nr.'); $col = 0;
$sheet->setCellValueByColumnAndRow(1, $i, 'Dateiname'); $sheet->setCellValueByColumnAndRow($col++, $i, 'Dokumenten-Nr.');
$sheet->setCellValueByColumnAndRow(2, $i, 'Status'); $sheet->setCellValueByColumnAndRow($col++, $i, 'Dokumentenname');
$sheet->setCellValueByColumnAndRow(3, $i, 'Int. Version'); $sheet->setCellValueByColumnAndRow($col++, $i, 'Dateiname');
$sheet->setCellValueByColumnAndRow(4, $i, 'Prüfer'); $sheet->setCellValueByColumnAndRow($col++, $i, 'Status');
$sheet->setCellValueByColumnAndRow(5, $i, 'Prüfdatum'); $sheet->setCellValueByColumnAndRow($col++, $i, 'Int. Version');
$sheet->setCellValueByColumnAndRow(6, $i, 'Prüfkommentar'); $sheet->setCellValueByColumnAndRow($col++, $i, 'Prüfer');
$sheet->setCellValueByColumnAndRow(7, $i, 'Prüfstatus'); $sheet->setCellValueByColumnAndRow($col++, $i, 'Prüfdatum');
$sheet->setCellValueByColumnAndRow(8, $i, 'Freigeber'); $sheet->setCellValueByColumnAndRow($col++, $i, 'Prüfkommentar');
$sheet->setCellValueByColumnAndRow(9, $i, 'Freigabedatum'); $sheet->setCellValueByColumnAndRow($col++, $i, 'Prüfstatus');
$sheet->setCellValueByColumnAndRow(10, $i, 'Freigabekommentar'); $sheet->setCellValueByColumnAndRow($col++, $i, 'Freigeber');
$sheet->setCellValueByColumnAndRow(11, $i, 'Freigabestatus'); $sheet->setCellValueByColumnAndRow($col++, $i, 'Freigabedatum');
$sheet->setCellValueByColumnAndRow($col++, $i, 'Freigabekommentar');
$sheet->setCellValueByColumnAndRow($col++, $i, 'Freigabestatus');
$i++; $i++;
foreach($items as $item) { foreach($items as $item) {
$document = $item->getDocument(); $document = $item->getDocument();
@ -74,10 +77,12 @@ class SeedDMS_Download_Mgr {
$reviewStatus = $item->getReviewStatus(); $reviewStatus = $item->getReviewStatus();
$approvalStatus = $item->getApprovalStatus(); $approvalStatus = $item->getApprovalStatus();
$sheet->setCellValueByColumnAndRow(0, $i, $document->getID()); $col = 0;
$sheet->setCellValueByColumnAndRow(1, $i, $document->getID()."-".$item->getOriginalFileName()); $sheet->setCellValueByColumnAndRow($col++, $i, $document->getID());
$sheet->setCellValueByColumnAndRow(2, $i, getOverallStatusText($status['status'])); $sheet->setCellValueByColumnAndRow($col++, $i, $document->getName());
$sheet->setCellValueByColumnAndRow(3, $i, $item->getVersion()); $sheet->setCellValueByColumnAndRow($col++, $i, $document->getID()."-".$item->getOriginalFileName());
$sheet->setCellValueByColumnAndRow($col++, $i, getOverallStatusText($status['status']));
$sheet->setCellValueByColumnAndRow($col++, $i, $item->getVersion());
$l = $i; $l = $i;
$k = $i; $k = $i;
if($reviewStatus) { if($reviewStatus) {
@ -100,12 +105,14 @@ class SeedDMS_Download_Mgr {
} }
break; break;
} }
$sheet->setCellValueByColumnAndRow(4, $l, $reqName); $tcol = $col;
$sheet->setCellValueByColumnAndRow(5, $l, ($r['status']==1 || $r['status']==-1) ? $r['date'] : ""); $sheet->setCellValueByColumnAndRow($tcol++, $l, $reqName);
$sheet->setCellValueByColumnAndRow(6, $l, $r['comment']); $sheet->setCellValueByColumnAndRow($tcol++, $l, ($r['status']==1 || $r['status']==-1) ? $r['date'] : "");
$sheet->setCellValueByColumnAndRow(7, $l, getReviewStatusText($r["status"])); $sheet->setCellValueByColumnAndRow($tcol++, $l, $r['comment']);
$sheet->setCellValueByColumnAndRow($tcol++, $l, getReviewStatusText($r["status"]));
$l++; $l++;
} }
$col = $tcol;
$l--; $l--;
} }
if($approvalStatus) { if($approvalStatus) {
@ -128,12 +135,14 @@ class SeedDMS_Download_Mgr {
} }
break; break;
} }
$sheet->setCellValueByColumnAndRow(8, $k, $reqName); $tcol = $col;
$sheet->setCellValueByColumnAndRow(9, $k, ($r['status']==1 || $r['status']==-1) ?$r['date'] : ""); $sheet->setCellValueByColumnAndRow($tcol++, $k, $reqName);
$sheet->setCellValueByColumnAndRow(10, $k, $r['comment']); $sheet->setCellValueByColumnAndRow($tcol++, $k, ($r['status']==1 || $r['status']==-1) ?$r['date'] : "");
$sheet->setCellValueByColumnAndRow(11, $k, getReviewStatusText($r["status"])); $sheet->setCellValueByColumnAndRow($tcol++, $k, $r['comment']);
$sheet->setCellValueByColumnAndRow($tcol++, $k, getApprovalStatusText($r["status"]));
$k++; $k++;
} }
$col = $tcol;
$k--; $k--;
} }
$i = max($l, $k); $i = max($l, $k);
@ -152,7 +161,7 @@ class SeedDMS_Download_Mgr {
} }
$file = tempnam("/tmp", "export-list-"); $file = tempnam("/tmp", "export-list-");
$this->createToc($file, $this->items); $this->createToc($file);
$zip = new ZipArchive(); $zip = new ZipArchive();
$prefixdir = date('Y-m-d', time()); $prefixdir = date('Y-m-d', time());