From 3ea51f5680a98517d0708053b818dfa8004ead6a Mon Sep 17 00:00:00 2001 From: ccheng Date: Tue, 25 Feb 2025 09:48:13 +0100 Subject: [PATCH] fix(HumanResources/Export): export empployee with custom fields --- tine20/HumanResources/Export/Xls.php | 32 ---- .../Export/definitions/hr_default_newcsv.xml | 163 ++++++++++++++++++ .../Export/definitions/hr_default_xls.xml | 55 ------ .../definitions/hr_xls_current_columns.xml | 14 -- tine20/HumanResources/translations/de.po | 6 +- tine20/HumanResources/translations/en.po | 3 - .../HumanResources/translations/template.pot | 3 - tine20/Tinebase/Export/CsvNew.php | 21 +++ 8 files changed, 187 insertions(+), 110 deletions(-) delete mode 100644 tine20/HumanResources/Export/Xls.php create mode 100644 tine20/HumanResources/Export/definitions/hr_default_newcsv.xml delete mode 100644 tine20/HumanResources/Export/definitions/hr_default_xls.xml delete mode 100644 tine20/HumanResources/Export/definitions/hr_xls_current_columns.xml diff --git a/tine20/HumanResources/Export/Xls.php b/tine20/HumanResources/Export/Xls.php deleted file mode 100644 index 07626bf447d..00000000000 --- a/tine20/HumanResources/Export/Xls.php +++ /dev/null @@ -1,32 +0,0 @@ - - * @copyright Copyright (c) 2013 Metaways Infosystems GmbH (http://www.metaways.de) - * - */ - -/** - * HumanResources xls generation class - * - * @package HumanResources - * @subpackage Export - */ -class HumanResources_Export_Xls extends Tinebase_Export_Spreadsheet_Xls -{ - /** - * @var string $_applicationName - */ - protected $_applicationName = 'HumanResources'; - - /** - * default export definition name - * - * @var string - */ - protected $_defaultExportname = 'hr_default_xls'; -} diff --git a/tine20/HumanResources/Export/definitions/hr_default_newcsv.xml b/tine20/HumanResources/Export/definitions/hr_default_newcsv.xml new file mode 100644 index 00000000000..4f19e90c542 --- /dev/null +++ b/tine20/HumanResources/Export/definitions/hr_default_newcsv.xml @@ -0,0 +1,163 @@ + + + HumanResources_Model_Employee + hr_default_newcsv + + export + Tinebase_Export_CsvNew + default csv employee export definition with custom fields + true + 1 +
1
+ + number + ASC + + + + number +
Number
+
+ + account_id +
Account
+
+ + description +
Description
+
+ + countryname +
Country
+
+ + locality +
Locality
+
+ + postalcode +
Postalcode
+
+ + region +
Region
+
+ + street +
Street
+
+ + street2 +
Street 2
+
+ + email +
E-Mail
+
+ + tel_home +
Telephone Number
+
+ + tel_cell +
Cell Phone Number
+
+ + title +
Title
+
+ + salutation +
Salutation
+
+ + n_family +
Last Name
+
+ + n_given +
First Name
+
+ + n_fn +
Employee name
+
+ + bday +
Birthday
+
+ + bank_account_holder +
Account Holder
+
+ + bank_account_number +
Account Number
+
+ + iban +
IBAN
+
+ + bic +
BIC
+
+ + bank_name +
Bank Name
+
+ + bank_code_number +
Code Number
+
+ + employment_begin +
Employment begin
+
+ + employment_end +
Employment end
+
+ + supervisor_id +
Supervisor
+
+ + division_id +
Division
+
+ + health_insurance +
Health Insurance
+
+ + profession +
Profession
+
+ + position +
Position
+
+ + created_by +
Created By
+
+ + creation_time +
Creation Time
+
+ + last_modified_by +
Last Modified By
+
+ + last_modified_time +
Last Modified Time
+
+ + tags +
Tags
+ tags +
+
+
diff --git a/tine20/HumanResources/Export/definitions/hr_default_xls.xml b/tine20/HumanResources/Export/definitions/hr_default_xls.xml deleted file mode 100644 index dc08311ef3b..00000000000 --- a/tine20/HumanResources/Export/definitions/hr_default_xls.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - HumanResources_Model_Employee - hr_default_xls - export - HumanResources_Export_Xls - default xls employee export definition -
1
- - number - account_id - description - countryname - locality - postalcode - region - street - street2 - email - tel_home - tel_cell - title - salutation - n_family - n_given - n_fn - bday - bank_account_holder - bank_account_number - bank_name - bank_code_number - employment_begin - employment_end - supervisor_id - division_id - health_insurance - profession - - created_by - - - creation_time - - - last_modified_by - - - last_modified_time - - - tags - tags - - -
diff --git a/tine20/HumanResources/Export/definitions/hr_xls_current_columns.xml b/tine20/HumanResources/Export/definitions/hr_xls_current_columns.xml deleted file mode 100644 index ae1dbaeeac6..00000000000 --- a/tine20/HumanResources/Export/definitions/hr_xls_current_columns.xml +++ /dev/null @@ -1,14 +0,0 @@ - - - HumanResources_Model_Employee - hr_xls_current_columns - - - export - HumanResources_Export_Xls - tinebase-action-export-xls - true - 600 - multi - true - diff --git a/tine20/HumanResources/translations/de.po b/tine20/HumanResources/translations/de.po index e5e417ea54b..464af019810 100644 --- a/tine20/HumanResources/translations/de.po +++ b/tine20/HumanResources/translations/de.po @@ -260,9 +260,6 @@ msgstr "Nicht erlaubt!" msgid "It's only allowed to book remaining vacation days from years in the past!" msgstr "Es ist nur erlaubt, Resturlaub aus vergangenen Jahren zu buchen!" -msgid "Excel current columns" -msgstr "Excel angezeigte Spalten" - msgid "Monthly Report (Clock Times)" msgstr "Monatsbericht (Stempelzeiten)" @@ -1288,3 +1285,6 @@ msgstr "Sonderzahlung" msgid "[H] Short Business trip" msgstr "[Z] Kurze Dienstreise" + +#~ msgid "Excel current columns" +#~ msgstr "Excel angezeigte Spalten" diff --git a/tine20/HumanResources/translations/en.po b/tine20/HumanResources/translations/en.po index b2eb02cd59b..2e874b8106f 100644 --- a/tine20/HumanResources/translations/en.po +++ b/tine20/HumanResources/translations/en.po @@ -245,9 +245,6 @@ msgstr "Not allowed!" msgid "It's only allowed to book remaining vacation days from years in the past!" msgstr "It's only allowed to book remaining vacation days from years in the past!" -msgid "Excel current columns" -msgstr "Excel current columns" - msgid "Monthly Report (Clock Times)" msgstr "Monthly Report (Clock Times)" diff --git a/tine20/HumanResources/translations/template.pot b/tine20/HumanResources/translations/template.pot index b1626e59cb8..40f4d71cc05 100644 --- a/tine20/HumanResources/translations/template.pot +++ b/tine20/HumanResources/translations/template.pot @@ -245,9 +245,6 @@ msgstr "" msgid "It's only allowed to book remaining vacation days from years in the past!" msgstr "" -msgid "Excel current columns" -msgstr "" - msgid "Monthly Report (Clock Times)" msgstr "" diff --git a/tine20/Tinebase/Export/CsvNew.php b/tine20/Tinebase/Export/CsvNew.php index 8847d295606..eb34329a0e1 100644 --- a/tine20/Tinebase/Export/CsvNew.php +++ b/tine20/Tinebase/Export/CsvNew.php @@ -152,6 +152,27 @@ protected function _startRow() protected function _endRow() { + if ($this->_config->columns && $this->_config->customFields) { + $record = new $this->_modelName(array(), true); + + $this->_fields = $record->getFields(); + $this->_fields = array_unique(array_merge( + array_diff($this->_fields, ['customfields']), + array_keys($this->_expandCustomFields) + )); + + foreach ($this->_expandCustomFields as $key => $value) { + if ($this->_currentRowType === self::ROW_TYPE_GENERIC_HEADER) { + $name = $this->_translate->_($value); + $this->_writeValue($name); + } + if ($this->_currentRowType === self::ROW_TYPE_RECORD) { + $record = $this->_currentRecord; + $this->_writeValue($this->_convertToString($record->{$key})); + } + } + } + if (false === self::fputcsv($this->_filehandle, $this->_currentRow, $this->_delimiter, $this->_enclosure, $this->_escape_char, $this->_charset)) { throw new Tinebase_Exception_Backend('could not write current row to csv stream');