switch to excel cell formats for report exports (#3178)
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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 %}
|
||||
<th class="text-center text-nowrap">
|
||||
{{ column|date_short }}
|
||||
</th>
|
||||
{% 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 %}
|
||||
|
||||
@@ -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 %}
|
||||
<th class="text-center text-nowrap">
|
||||
{{ column|month_name }} {{ column|date_format('Y') }}
|
||||
</th>
|
||||
{% 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 %}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
{% set usersTotalInternalRate = 0 %}
|
||||
{% set usersTotalRate = 0 %}
|
||||
<tr class="user">
|
||||
<td class="text-nowrap">
|
||||
<td class="text-nowrap"{% block user_column_cell_attribute %}{% endblock %}>
|
||||
{% 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 %}
|
||||
<th class="text-nowrap text-center total">
|
||||
<th class="text-nowrap text-center total{% block user_total_cell_class %}{% endblock %}"{% block user_total_cell_attribute %}{% endblock %}>
|
||||
{% if dataType == 'rate' %}
|
||||
{% block total_rate_user %}{% endblock %}
|
||||
{% elseif dataType == 'internalRate' %}
|
||||
@@ -65,7 +65,7 @@
|
||||
{% endif %}
|
||||
</th>
|
||||
{% for period in attribute(userPeriod, period_attribute) %}
|
||||
<td class="text-nowrap text-center day-total{% block period_cell_class %}{% endblock %}">
|
||||
<td class="text-nowrap text-center day-total{% block period_cell_class %}{% endblock %}"{% block period_cell_attribute %}{% endblock %}>
|
||||
{% if period.totalDuration > 0 or period.totalRate > 0 or period.totalInternalRate > 0 %}
|
||||
{% if dataType == 'rate' %}
|
||||
{% block rate %}{% endblock %}
|
||||
@@ -83,7 +83,7 @@
|
||||
<tfoot>
|
||||
<tr class="summary">
|
||||
<td>{{ dataTypeTitle|trans }}</td>
|
||||
<td class="text-center text-nowrap">
|
||||
<td class="text-center text-nowrap{% block total_period_cell_class %}{% endblock %}"{% block total_period_cell_attribute %}{% endblock %}>
|
||||
{% if dataType == 'rate' %}
|
||||
{% block total_rate %}
|
||||
{{ absoluteRate|money }}
|
||||
@@ -100,7 +100,7 @@
|
||||
</td>
|
||||
{% if dataType == 'rate' %}
|
||||
{% for id, total in totalsRate %}
|
||||
<td class="text-center text-nowrap">
|
||||
<td class="text-center text-nowrap{% block total_rate_period_cell_class %}{% endblock %}"{% block total_rate_period_cell_attribute %}{% endblock %}>
|
||||
{% block total_rate_period %}
|
||||
{{ total|money }}
|
||||
{% endblock %}
|
||||
@@ -108,7 +108,7 @@
|
||||
{% endfor %}
|
||||
{% elseif dataType == 'internalRate' %}
|
||||
{% for id, total in totalsInternalRate %}
|
||||
<td class="text-center text-nowrap">
|
||||
<td class="text-center text-nowrap{% block total_internal_rate_period_cell_class %}{% endblock %}"{% block total_internal_rate_period_cell_attribute %}{% endblock %}>
|
||||
{% block total_internal_rate_period %}
|
||||
{{ total|money }}
|
||||
{% endblock %}
|
||||
@@ -116,7 +116,7 @@
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
{% for id, total in totalsDuration %}
|
||||
<td class="text-center text-nowrap">
|
||||
<td class="text-center text-nowrap{% block total_duration_period_cell_class %}{% endblock %}"{% block total_duration_period_cell_attribute %}{% endblock %}>
|
||||
{% block total_duration_period %}
|
||||
{{ total|duration(decimal) }}
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user