diff --git a/src/Export/Base/AbstractSpreadsheetRenderer.php b/src/Export/Base/AbstractSpreadsheetRenderer.php index bdeb6e61..0fbdc524 100644 --- a/src/Export/Base/AbstractSpreadsheetRenderer.php +++ b/src/Export/Base/AbstractSpreadsheetRenderer.php @@ -45,11 +45,16 @@ abstract class AbstractSpreadsheetRenderer public const TIME_FORMAT = 'hh:mm'; public const DURATION_FORMAT = '[hh]:mm'; public const DURATION_DECIMAL = '#0.00'; + // https://support.microsoft.com/de-de/office/zahlenformatcodes-5026bbd6-04bc-48cd-bf33-80f18b4eae68 // Part 1 = positive; Part 2 = negative; Part 3 = zero; Part 4 = Text public const RATE_FORMAT_DEFAULT = '#.##0,00 [$%1$s];-#.##0,00 [$%1$s]'; public const RATE_FORMAT_LEFT = '_("%1$s"* #,##0.00_);_("%1$s"* -#,##0.00;_("%1$s"* "-"??_);_(@_)'; public const RATE_FORMAT = self::RATE_FORMAT_LEFT; + /** + * @internal used in html to excel exporter + */ + public const RATE_FORMAT_NO_CURRENCY = '#,##0.00;-#,##0.00'; protected $durationFormat = self::DURATION_FORMAT; protected $durationBase = 86400; diff --git a/templates/reporting/report_user_list_export.html.twig b/templates/reporting/report_user_list_export.html.twig index 604b8147..0716cb40 100644 --- a/templates/reporting/report_user_list_export.html.twig +++ b/templates/reporting/report_user_list_export.html.twig @@ -1,46 +1,59 @@ {% embed 'reporting/user_list_period_data.html.twig' %} + {% set dataTypeFormat = '' %} + {% if dataType == 'rate' or dataType == 'internalRate' %} + {% set dataTypeFormat = ' data-format="' ~ constant('App\\Export\\Base\\AbstractSpreadsheetRenderer::RATE_FORMAT_NO_CURRENCY') ~ '"' %} + {% elseif dataType == 'duration' %} + {% set dataTypeFormat = ' data-format="' ~ constant('App\\Export\\Base\\AbstractSpreadsheetRenderer::DURATION_DECIMAL') ~ '"' %} + {% endif %} {% block user_column %} {{ userPeriod.user.displayName }} {% endblock %} {% block duration -%} - =VALUE("{{ period.totalDuration|duration(true) }}") + {{ period.totalDuration / 3600 }} {%- endblock %} {% block total_duration -%} - =VALUE("{{ absoluteDuration|duration(true) }}") + {{ absoluteDuration / 3600 }} {%- endblock %} {% block total_duration_user -%} - =VALUE("{{ usersTotalDuration|duration(true) }}") + {{ usersTotalDuration / 3600 }} {%- endblock %} {% block total_duration_period -%} - =VALUE("{{ total|duration(true) }}") + {{ total / 3600 }} {%- endblock %} {% block rate %} - =VALUE("{{ period.totalRate|money }}") + {{ period.totalRate }} {% endblock %} {% block total_rate %} - =VALUE("{{ absoluteRate|money }}") + {{ absoluteRate }} {% endblock %} {% block total_rate_user %} - =VALUE("{{ usersTotalRate|money }}") + {{ usersTotalRate }} {% endblock %} {% block total_rate_period %} - =VALUE("{{ total|money }}") + {{ total }} {% endblock %} {% block internal_rate %} - =VALUE("{{ period.totalInternalRate|money }}") + {{ period.totalInternalRate }} {% endblock %} {% block total_internal_rate %} - =VALUE("{{ absoluteInternalRate|money }}") + {{ absoluteInternalRate }} {% endblock %} {% block total_internal_rate_user %} - =VALUE("{{ usersTotalInternalRate|money }}") + {{ usersTotalInternalRate }} {% endblock %} {% block total_internal_rate_period %} - =VALUE("{{ total|money }}") + {{ total }} {% endblock %} {% block period_name %} {{ column|date_short }} {% endblock %} + {% block user_column_cell_attribute %} data-format="@"{% endblock %} + {% block period_cell_attribute %}{{ dataTypeFormat|raw }}{% endblock %} + {% block user_total_cell_attribute %}{{ dataTypeFormat|raw }}{% endblock %} + {% block total_period_cell_attribute %}{{ dataTypeFormat|raw }}{% endblock %} + {% block total_rate_period_cell_attribute %}{{ dataTypeFormat|raw }}{% endblock %} + {% block total_internal_rate_period_cell_attribute %}{{ dataTypeFormat|raw }}{% endblock %} + {% block total_duration_period_cell_attribute %}{{ dataTypeFormat|raw }}{% endblock %} {% endembed %} diff --git a/templates/reporting/report_user_list_monthly_export.html.twig b/templates/reporting/report_user_list_monthly_export.html.twig index 3b9d3821..698ceecf 100644 --- a/templates/reporting/report_user_list_monthly_export.html.twig +++ b/templates/reporting/report_user_list_monthly_export.html.twig @@ -1,46 +1,59 @@ {% embed 'reporting/user_list_period_data.html.twig' %} + {% set dataTypeFormat = '' %} + {% if dataType == 'rate' or dataType == 'internalRate' %} + {% set dataTypeFormat = ' data-format="' ~ constant('App\\Export\\Base\\AbstractSpreadsheetRenderer::RATE_FORMAT_NO_CURRENCY') ~ '"' %} + {% elseif dataType == 'duration' %} + {% set dataTypeFormat = ' data-format="' ~ constant('App\\Export\\Base\\AbstractSpreadsheetRenderer::DURATION_DECIMAL') ~ '"' %} + {% endif %} {% block user_column %} {{ userPeriod.user.displayName }} {% endblock %} {% block duration -%} - =VALUE("{{ period.totalDuration|duration(true) }}") - {%- endblock %} - {% block total_duration_user -%} - =VALUE("{{ usersTotalDuration|duration(true) }}") + {{ period.totalDuration / 3600 }} {%- endblock %} {% block total_duration -%} - =VALUE("{{ absoluteDuration|duration(true) }}") + {{ absoluteDuration / 3600 }} + {%- endblock %} + {% block total_duration_user -%} + {{ usersTotalDuration / 3600 }} {%- endblock %} {% block total_duration_period -%} - =VALUE("{{ total|duration(true) }}") + {{ total / 3600 }} {%- endblock %} {% block rate %} - =VALUE("{{ period.totalRate|money }}") + {{ period.totalRate }} {% endblock %} {% block total_rate %} - =VALUE("{{ absoluteRate|money }}") + {{ absoluteRate }} {% endblock %} {% block total_rate_user %} - =VALUE("{{ usersTotalRate|money }}") + {{ usersTotalRate }} {% endblock %} {% block total_rate_period %} - =VALUE("{{ total|money }}") + {{ total }} {% endblock %} {% block internal_rate %} - =VALUE("{{ period.totalInternalRate|money }}") + {{ period.totalInternalRate }} {% endblock %} {% block total_internal_rate %} - =VALUE("{{ absoluteInternalRate|money }}") + {{ absoluteInternalRate }} {% endblock %} {% block total_internal_rate_user %} - =VALUE("{{ usersTotalInternalRate|money }}") + {{ usersTotalInternalRate }} {% endblock %} {% block total_internal_rate_period %} - =VALUE("{{ total|money }}") + {{ total }} {% endblock %} {% block period_name %} {{ column|month_name }} {{ column|date_format('Y') }} {% endblock %} + {% block user_column_cell_attribute %} data-format="@"{% endblock %} + {% block period_cell_attribute %}{{ dataTypeFormat|raw }}{% endblock %} + {% block user_total_cell_attribute %}{{ dataTypeFormat|raw }}{% endblock %} + {% block total_period_cell_attribute %}{{ dataTypeFormat|raw }}{% endblock %} + {% block total_rate_period_cell_attribute %}{{ dataTypeFormat|raw }}{% endblock %} + {% block total_internal_rate_period_cell_attribute %}{{ dataTypeFormat|raw }}{% endblock %} + {% block total_duration_period_cell_attribute %}{{ dataTypeFormat|raw }}{% endblock %} {% endembed %} diff --git a/templates/reporting/user_list_period_data.html.twig b/templates/reporting/user_list_period_data.html.twig index 2bc5fbbd..e79358da 100644 --- a/templates/reporting/user_list_period_data.html.twig +++ b/templates/reporting/user_list_period_data.html.twig @@ -31,7 +31,7 @@ {% set usersTotalInternalRate = 0 %} {% set usersTotalRate = 0 %} - + {% block user_column %} {% from "macros/widgets.html.twig" import label_dot %} {{ label_dot(userPeriod.user.displayName, userPeriod.user.color) }} @@ -55,7 +55,7 @@ {% set totalsInternalRate = totalsInternalRate|merge({(reportDateKey): (totalsInternalRate[reportDateKey] + period.totalInternalRate)}) %} {% set totalsRate = totalsRate|merge({(reportDateKey): (totalsRate[reportDateKey] + period.totalRate)}) %} {% endfor %} - + {% if dataType == 'rate' %} {% block total_rate_user %}{% endblock %} {% elseif dataType == 'internalRate' %} @@ -65,7 +65,7 @@ {% endif %} {% for period in attribute(userPeriod, period_attribute) %} - + {% if period.totalDuration > 0 or period.totalRate > 0 or period.totalInternalRate > 0 %} {% if dataType == 'rate' %} {% block rate %}{% endblock %} @@ -83,7 +83,7 @@ {{ dataTypeTitle|trans }} - + {% if dataType == 'rate' %} {% block total_rate %} {{ absoluteRate|money }} @@ -100,7 +100,7 @@ {% if dataType == 'rate' %} {% for id, total in totalsRate %} - + {% block total_rate_period %} {{ total|money }} {% endblock %} @@ -108,7 +108,7 @@ {% endfor %} {% elseif dataType == 'internalRate' %} {% for id, total in totalsInternalRate %} - + {% block total_internal_rate_period %} {{ total|money }} {% endblock %} @@ -116,7 +116,7 @@ {% endfor %} {% else %} {% for id, total in totalsDuration %} - + {% block total_duration_period %} {{ total|duration(decimal) }} {% endblock %}