Tinebase_Export_Xls - clone row styles too
authorPaul Mehrer <p.mehrer@metaways.de>
Wed, 19 Jul 2017 16:26:09 +0000 (18:26 +0200)
committerPaul Mehrer <p.mehrer@metaways.de>
Thu, 20 Jul 2017 09:14:04 +0000 (11:14 +0200)
some calendar fixes too

Change-Id: I8bc373cd29411c7af493d303973e38ba599b6e29
Reviewed-on: http://gerrit.tine20.com/customers/5260
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Paul Mehrer <p.mehrer@metaways.de>
Tested-by: Paul Mehrer <p.mehrer@metaways.de>
tine20/Calendar/Export/GenericTrait.php
tine20/Calendar/Export/definitions/cal_resource_xls.xml
tine20/Tinebase/Export/Xls.php

index ec75557..e83a32c 100644 (file)
@@ -55,7 +55,7 @@ trait Calendar_Export_GenericTrait
 
         if ($periodFilter) {
             $this->_from = $periodFilter->getFrom();
-            $this->_until = $periodFilter->getUntil();
+            $this->_until = $periodFilter->getUntil()->subSecond(1);
         }
 
         parent::__construct($_filter, $_controller, $_additionalOptions);
index 3fac20d..e0a12be 100644 (file)
     <plugin>Calendar_Export_Resource_Xls</plugin>
     <icon_class>tinebase-action-export-xls</icon_class>
     <template>tine20:///Tinebase/folders/shared/export/templates/Calendar/calendar_resource_export.xlsx</template>
+    <virtualFields>
+        <virtualField>
+            <name>location</name>
+            <relatedModel>Addressbook_Model_Contact</relatedModel>
+            <relatedDegree>child</relatedDegree>
+            <type>SITE</type>
+        </virtualField>
+    </virtualFields>
+    <keyFields>
+        <keyField>
+            <name>resourceTypes</name>
+            <propertyName>type</propertyName>
+        </keyField>
+        <keyField>
+            <name>freebusyTypes</name>
+            <propertyName>busy_type</propertyName>
+        </keyField>
+        <keyField>
+            <name>attendeeStatus</name>
+            <propertyName>status</propertyName>
+        </keyField>
+    </keyFields>
 </config>
index 849365e..070c880 100644 (file)
@@ -40,6 +40,8 @@ class Tinebase_Export_Xls extends Tinebase_Export_Abstract implements Tinebase_R
 
     protected $_cloneRow = null;
 
+    protected $_cloneRowStyles = array();
+
     protected $_excelVersion = null;
 
 
@@ -159,6 +161,11 @@ class Tinebase_Export_Xls extends Tinebase_Export_Abstract implements Tinebase_R
                 $cell->setValue($newRow['value'] . '#' . $this->_rowCount);
                 $cell->setXfIndex($newRow['XFIndex']);
             }
+
+            $rowDimension = $sheet->getRowDimension($newRowOffset);
+            foreach($this->_cloneRowStyles as $func => $value) {
+                call_user_func(array($rowDimension, $func), $value);
+            }
         }
     }
 
@@ -327,6 +334,7 @@ class Tinebase_Export_Xls extends Tinebase_Export_Abstract implements Tinebase_R
 
         $rowIter = $sheet->getRowIterator();
         /** @var PHPExcel_Worksheet_Row $row */
+        /** @noinspection PhpUnusedLocalVariableInspection */
         foreach($rowIter as $row) {
             ++$this->_rowCount;
         }
@@ -337,13 +345,15 @@ class Tinebase_Export_Xls extends Tinebase_Export_Abstract implements Tinebase_R
         // TODO header row?
 
         if (null === ($block = $this->_findCell('${ROW}'))) {
-            return $this->_findFirstFreeRow();
+            $this->_findFirstFreeRow();
+            return;
         }
         $startColumn = $block->getColumn();
         $this->_rowOffset = $block->getRow();
 
         if (null === ($block = $this->_findCell('${/ROW}'))) {
-            return $this->_findFirstFreeRow();
+            $this->_findFirstFreeRow();
+            return;
         }
 
         $this->_dumpRecords = false;
@@ -363,7 +373,17 @@ class Tinebase_Export_Xls extends Tinebase_Export_Abstract implements Tinebase_R
 
         /** @var  $rowIterator */
         $rowIterator = $sheet->getRowIterator($this->_rowOffset);
-        $cellIterator = $rowIterator->current()->getCellIterator($startColumn, $endColumn);
+        $row = $rowIterator->current();
+        $rowDimension = $sheet->getRowDimension($row->getRowIndex());
+        $this->_cloneRowStyles = array(
+            'setCollapsed'      => $rowDimension->getCollapsed(),
+            'setOutlineLevel'   => $rowDimension->getOutlineLevel(),
+            'setRowHeight'      => $rowDimension->getRowHeight(),
+            'setVisible'        => $rowDimension->getVisible(),
+            'setXfIndex'        => $rowDimension->getXfIndex(),
+            'setZeroHeight'     => $rowDimension->getZeroHeight()
+        );
+        $cellIterator = $row->getCellIterator($startColumn, $endColumn);
 
         $replace = array('${ROW}', '${/ROW}');
         /** @var PHPExcel_Cell $cell */