Skip to content
This repository has been archived by the owner on Dec 27, 2023. It is now read-only.

Commit

Permalink
Merge branch 'pu/pm/TBMunicipalityKeyBevoelkerungsstand' into '2022.11'
Browse files Browse the repository at this point in the history
tweak(TB MunicipalityKey) Import parses/requires bevölkerungsstand

See merge request tine20/tine20!2262
  • Loading branch information
paulmhh committed May 12, 2022
2 parents 55c21a5 + b6bc4f5 commit 08d7c45
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion tine20/Tinebase/Import/MunicipalityKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @subpackage Import
* @license http://www.gnu.org/licenses/agpl.html AGPL Version 3
* @author Philipp Schüle <p.schuele@metaways.de>
* @copyright Copyright (c) 2015 Metaways Infosystems GmbH (http://www.metaways.de)
* @copyright Copyright (c) 2021-2022 Metaways Infosystems GmbH (http://www.metaways.de)
*/

/**
Expand All @@ -18,6 +18,7 @@
class Tinebase_Import_MunicipalityKey extends Tinebase_Import_Xls_Abstract
{
protected $_gebietsstand = null;
protected $_bevoelkerungsstand = null;

/**
* constructs a new importer from given config
Expand All @@ -30,6 +31,23 @@ public function __construct(array $_options = array())

}

/**
* do something before the import
*
* @param mixed $_resource
*/
protected function _beforeImport($_resource = NULL)
{
parent::_beforeImport($_resource);

if (null === $this->_bevoelkerungsstand && $this->_worksheet && $this->_worksheet->cellExists('J5') &&
preg_match('/(\d\d)\.(\d\d)\.(\d\d\d\d)/',
$this->_worksheet->getCell('J5')->getValue(), $m)) {
$this->_bevoelkerungsstand = new Tinebase_DateTime($m[3] . '-' . $m[2] . '-' . $m[1]);
$this->_bevoelkerungsstand->hasTime(false);
}
}

/**
* map data to the fields of the mapping array. We don't have a headline and therefor have to use the order
*
Expand Down Expand Up @@ -75,9 +93,13 @@ protected function _importRecord($_record, $_resolveStrategy = NULL, $_recordDat
if (null === $this->_gebietsstand) {
throw new Tinebase_Exception_UnexpectedValue('could not find Gebietsstand in import data and none provided by importer');
}
if (null === $this->_bevoelkerungsstand) {
throw new Tinebase_Exception_UnexpectedValue('could not find Bevölkerungsstand in import data and none provided by importer');
}
$_record->{Tinebase_Model_MunicipalityKey::FLD_ARS_COMBINED} =
$_record->arsLand . $_record->arsRB . $_record->arsKreis . $_record->arsVB . $_record->arsGem;
$_record->{Tinebase_Model_MunicipalityKey::FLD_GEBIETSSTAND} = $this->_gebietsstand;
$_record->{Tinebase_Model_MunicipalityKey::FLD_BEVOELKERUNGSSTAND} = $this->_bevoelkerungsstand;
$filter->getFilter(Tinebase_Model_MunicipalityKey::FLD_ARS_COMBINED)->setValue(
$_record->{Tinebase_Model_MunicipalityKey::FLD_ARS_COMBINED}
);
Expand Down
2 changes: 1 addition & 1 deletion tine20/Tinebase/Import/Xls/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use PhpOffice\PhpSpreadsheet\IOFactory;
use PhpOffice\PhpSpreadsheet\Shared\Date;
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Worksheet;
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
use PhpOffice\PhpSpreadsheet\Worksheet\Row;
use PhpOffice\PhpSpreadsheet\Worksheet\RowIterator;

Expand Down

0 comments on commit 08d7c45

Please sign in to comment.