new user-year reporting and data-type chooser (#3155)

This commit is contained in:
Kevin Papst
2022-02-16 12:18:04 +01:00
committed by GitHub
parent 1852d71974
commit 85a63c4b78
58 changed files with 1862 additions and 683 deletions

View File

@@ -7,7 +7,7 @@
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% block box_before %}
{{ form_start(form, {'attr': {'class': 'form-inline'}}) }}
{{ form_start(form, {'attr': {'class': 'form-inline', 'id': 'user-filter-form'}}) }}
{% endblock %}
{% block box_after %}
{{ form_end(form) }}
@@ -19,78 +19,35 @@
{{ widgets.username(user) }}
{% endif %}
{{ form_widget(form.date) }}
<div class="btn-group"{% if form.sumType.vars.choices|length <= 1 %} style="display: none"{% endif %}>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="{{ 'display'|icon }}"></i> <span class="caret"></span>
</button>
<ul class="dropdown-menu checkbox-menu">
<li>
{{ form_widget(form.sumType) }}
</li>
</ul>
</div>
{% endblock %}
{% block box_body_class %}{{ box_id }} table-responsive no-padding{% endblock %}
{% block box_body %}
{% set totals = {'totals': 0} %}
{% set columns = 2 %}
<table class="table table-bordered table-hover dataTable">
<thead>
<tr>
<th>&nbsp;</th>
<th>&nbsp;</th>
{% for day in days.dateTimes %}
<th class="text-center text-nowrap{% if day is weekend %} weekend{% endif %}{% if day is today %} today{% endif %}">
{{ day|date_weekday }}
</th>
{% set columns = columns + 1 %}
{% set totals = totals|merge({(day|report_date): 0}) %}
{% endfor %}
</tr>
</thead>
<tbody>
{% set oldCustomer = null %}
{% for pid, project in rows|sort((a,b) => a.project.customer.id <=> b.project.customer.id) %}
{% if oldCustomer is null or oldCustomer != project.project.customer.id %}
{% set oldCustomer = project.project.customer.id %}
<tr class="summary">
<td colspan="{{ columns }}">{{ widgets.label_customer(project.project.customer) }}</td>
</tr>
{% endif %}
{% set totals = totals|merge({'totals': (totals['totals'] + project.duration)}) %}
<tr class="project">
<td class="text-nowrap">
<strong>{{ widgets.label_project(project.project) }}</strong>
</td>
<th class="text-nowrap text-center total">{{ project.duration|duration }}</th>
{% for day in project.days.days %}
<td class="text-nowrap text-center day-total{% if day.date is weekend %} weekend{% endif %}{% if day.date is today %} today{% endif %}">
{% if day.duration > 0 %}
{% set totals = totals|merge({(day.date|report_date): (totals[day.date|report_date] + day.duration)}) %}
<strong>{{ day.duration|duration }}</strong>
{% endif %}
</td>
{% endfor %}
</tr>
{% for activity in project.activities %}
<tr class="activity">
<td class="text-nowrap">
{{ widgets.label_activity(activity.activity) }}
</td>
<th class="text-nowrap text-center total">{{ activity.duration|duration }}</th>
{% for day in activity.days.days %}
<td class="text-nowrap text-center day-total{% if day.date is weekend %} weekend{% endif %}{% if day.date is today %} today{% endif %}">
{% if day.duration > 0 %}
{{ day.duration|duration }}
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
{% endfor %}
</tbody>
<tfoot>
<tr class="summary">
<td>{{ 'stats.durationTotal'|trans }}</td>
<td class="text-nowrap text-center total">{{ totals['totals']|duration }}</td>
{% for day in days.dateTimes %}
<td class="text-nowrap text-center day-total{% if day is weekend %} weekend{% endif %}">
{{ totals[day|report_date]|duration }}
</td>
{% endfor %}
</tr>
</tfoot>
</table>
{% embed 'reporting/report_by_user_data.html.twig' %}
{% block period_name %}
<th class="text-center text-nowrap{% if column is weekend %} weekend{% endif %}{% if column is today %} today{% endif %}">
{{ column|date_weekday }}
</th>
{% endblock %}
{% block column_classes_project -%}
{% if column.date is weekend %} weekend{% endif %}{% if column.date is today %} today{% endif %}
{%- endblock %}
{% block column_classes_activity -%}
{% if column.date is weekend %} weekend{% endif %}{% if column.date is today %} today{% endif %}
{%- endblock %}
{% block column_classes_total -%}
{% if column is weekend %} weekend{% endif %}
{%- endblock %}
{% endembed %}
{% endblock %}
{% endembed %}
@@ -100,13 +57,8 @@
{{ parent() }}
<script type="text/javascript">
document.addEventListener('kimai.initialized', function() {
{% if form.user is defined %}
jQuery('#{{ form.user.vars.id }}').on('change', function(ev) {
jQuery(this).closest('form').submit();
});
{% endif %}
jQuery('#{{ form.date.vars.id }}').on('change', function(ev) {
jQuery(this).closest('form').submit();
jQuery('#user-filter-form').on('change', function(ev) {
jQuery(this).submit();
});
});
</script>

View File

@@ -0,0 +1,141 @@
{% import "macros/widgets.html.twig" as widgets %}
{%- set absoluteDuration = 0 -%}
{%- set absoluteInternalRate = 0 -%}
{%- set absoluteRate = 0 -%}
{%- set totalsDuration = {} -%}
{%- set totalsInternalRate = {} -%}
{%- set totalsRate = {} -%}
{% if dataType == 'rate' %}
{% set dataTypeTitle = 'stats.amountTotal' %}
{% elseif dataType == 'internalRate' %}
{% set dataTypeTitle = 'label.rate_internal' %}
{% else %}
{% set dataTypeTitle = 'stats.durationTotal' %}
{% endif %}
{% set columns = 2 %}
{% set totalCurrency = false %}
<table class="table table-bordered table-hover dataTable">
<thead>
<tr>
<th>&nbsp;</th>
<th class="text-center reportDataTypeTitle">{{ dataTypeTitle|trans }}</th>
{% for column in period.dateTimes %}
{% block period_name %}{% endblock %}
{% set columns = columns + 1 %}
{% set dateKey = column|report_date %}
{% set totalsDuration = totalsDuration|merge({(dateKey): 0}) %}
{% set totalsInternalRate = totalsInternalRate|merge({(dateKey): 0}) %}
{% set totalsRate = totalsRate|merge({(dateKey): 0}) %}
{% endfor %}
</tr>
</thead>
<tbody>
{% set oldCustomer = null %}
{% for project in rows|sort((a,b) => a.project.customer.id <=> b.project.customer.id) %}
{% set currency = project.project.customer.currency %}
{% if oldCustomer is null or oldCustomer != project.project.customer.id %}
{% set oldCustomer = project.project.customer.id %}
{% if totalCurrency is same as (false) %}
{% set totalCurrency = currency %}
{% elseif project.project.customer.currency != totalCurrency %}
{% set totalCurrency = null %}
{% endif %}
<tr class="summary">
<td colspan="{{ columns }}">{{ widgets.label_customer(project.project.customer) }}</td>
</tr>
{% endif %}
{% set absoluteDuration = absoluteDuration + project.duration %}
{% set absoluteInternalRate = absoluteInternalRate + project.internalRate %}
{% set absoluteRate = absoluteRate + project.rate %}
<tr class="project">
<td class="text-nowrap">
<strong>{{ widgets.label_project(project.project) }}</strong>
</td>
<td class="text-nowrap text-center total">
{% if dataType == 'rate' %}
{{ project.rate|money(currency) }}
{% elseif dataType == 'internalRate' %}
{{ project.internalRate|money(currency) }}
{% else %}
{{ project.duration|duration(decimal) }}
{% endif %}
</td>
{% for column in project.data.data %}
{% set dateKey = column.date|report_date %}
<td class="text-nowrap text-center day-total {% block column_classes_project %}{% endblock %}">
{% if column.duration > 0 or column.rate > 0 or column.internalRate > 0 %}
{% if dataType == 'rate' %}
{% set totalsRate = totalsRate|merge({(dateKey): (totalsRate[dateKey] + column.rate)}) %}
<strong>{{ column.rate|money(currency) }}</strong>
{% elseif dataType == 'internalRate' %}
{% set totalsInternalRate = totalsInternalRate|merge({(dateKey): (totalsInternalRate[dateKey] + column.internalRate)}) %}
<strong>{{ column.internalRate|money(currency) }}</strong>
{% else %}
{% set totalsDuration = totalsDuration|merge({(dateKey): (totalsDuration[dateKey] + column.duration)}) %}
<strong>{{ column.duration|duration(decimal) }}</strong>
{% endif %}
{% endif %}
</td>
{% endfor %}
</tr>
{% for activity in project.activities %}
<tr class="activity">
<td class="text-nowrap">
{{ widgets.label_activity(activity.activity) }}
</td>
<td class="text-nowrap text-center">
{% if dataType == 'rate' %}
{{ activity.rate|money(currency) }}
{% elseif dataType == 'internalRate' %}
{{ activity.internalRate|money(currency) }}
{% else %}
{{ activity.duration|duration(decimal) }}
{% endif %}
</td>
{% for column in activity.data.data %}
<td class="text-nowrap text-center day-total {% block column_classes_activity %}{% endblock %}">
{% if column.duration > 0 or column.rate > 0 or column.internalRate > 0 %}
{% if dataType == 'rate' %}
{{ column.rate|money(currency) }}
{% elseif dataType == 'internalRate' %}
{{ column.internalRate|money(currency) }}
{% else %}
{{ column.duration|duration(decimal) }}
{% endif %}
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
{% endfor %}
</tbody>
{% if totalCurrency is same as (false) %}
{% set totalCurrency = null %}
{% endif %}
<tfoot>
<tr class="summary">
<td>{{ dataTypeTitle|trans }}</td>
<td class="text-nowrap text-center total">
{% if dataType == 'rate' %}
{{ absoluteRate|money(totalCurrency) }}
{% elseif dataType == 'internalRate' %}
{{ absoluteInternalRate|money(totalCurrency) }}
{% else %}
{{ absoluteDuration|duration(decimal) }}
{% endif %}
</td>
{% for column in period.dateTimes %}
{% set dateKey = column|report_date %}
<td class="text-nowrap text-center day-total {% block column_classes_total %}{% endblock %}">
{% if dataType == 'rate' %}
{{ totalsRate[dateKey]|money(totalCurrency) }}
{% elseif dataType == 'internalRate' %}
{{ totalsInternalRate[dateKey]|money(totalCurrency) }}
{% else %}
{{ totalsDuration[dateKey]|duration(decimal) }}
{% endif %}
</td>
{% endfor %}
</tr>
</tfoot>
</table>

View File

@@ -0,0 +1,62 @@
{% extends 'reporting/layout.html.twig' %}
{% block report_title %}{{ report_title|trans({}, 'reporting') }}{% endblock %}
{% block report %}
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% block box_before %}
{{ form_start(form, {'attr': {'class': 'form-inline', 'id': 'user-filter-form'}}) }}
{% endblock %}
{% block box_after %}
{{ form_end(form) }}
{% endblock %}
{% block box_title %}
{% if form.user is defined %}
{{ form_row(form.user, {'label': false}) }}
{% else %}
{{ widgets.username(user) }}
{% endif %}
{{ form_widget(form.date) }}
<div class="btn-group"{% if form.sumType.vars.choices|length <= 1 %} style="display: none"{% endif %}>
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="{{ 'display'|icon }}"></i> <span class="caret"></span>
</button>
<ul class="dropdown-menu checkbox-menu">
<li>
{{ form_widget(form.sumType) }}
</li>
</ul>
</div>
{% endblock %}
{% block box_body_class %}{{ box_id }} table-responsive no-padding{% endblock %}
{% block box_body %}
{% embed 'reporting/report_by_user_data.html.twig' %}
{% block period_name %}
<th class="text-center text-nowrap">
<a href="{{ path('report_user_month', {'date': column|report_date, 'sumType': dataType, 'user': user.id}) }}">
{{ column|month_name }}<br>
{{ column|date_format('Y') }}
</a>
</th>
{% endblock %}
{% block column_classes_project %}{% endblock %}
{% block column_classes_activity %}{% endblock %}
{% block column_classes_total %}{% endblock %}
{% endembed %}
{% endblock %}
{% endembed %}
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script type="text/javascript">
document.addEventListener('kimai.initialized', function() {
jQuery('#user-filter-form').on('change', function(ev) {
jQuery(this).submit();
});
});
</script>
{% endblock %}

View File

@@ -5,25 +5,60 @@
{% block report %}
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% from "macros/widgets.html.twig" import nothing_found %}
{% block box_before %}
{{ form_start(form, {'attr': {'class': 'form-inline'}}) }}
{{ form_start(form, {'attr': {'class': 'form-inline kimai-1.17', 'id': 'user-list-filter-form'}}) }}
{% endblock %}
{% block box_after %}
{{ form_end(form) }}
{% endblock %}
{% block box_title %}
{{ form_widget(form.date) }}
{% endblock %}
{% block box_tools %}
<button class="btn btn-default btn-sm" formaction="{{ path(export_route) }}" type="submit"><i class="{{ 'download'|icon }}"></i></button>
{% if form.sumType.vars.choices|length > 1 %}
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="{{ 'display'|icon }}"></i> <span class="caret"></span>
</button>
<ul class="dropdown-menu checkbox-menu">
<li>
{{ form_widget(form.sumType) }}
</li>
</ul>
</div>
{% endif %}
<button class="btn btn-primary" formaction="{{ path(export_route) }}" type="submit"><i class="{{ 'download'|icon }}"></i></button>
{% endblock %}
{% block box_body_class %}{{ box_id }} table-responsive {% if hasData %}no-padding{% endif %}{% endblock %}
{% block box_body %}
{% if not hasData %}
{{ widgets.nothing_found() }}
{{ nothing_found() }}
{% else %}
{% embed 'reporting/report_user_list_data.html.twig' %}{% endembed %}
{% embed 'reporting/user_list_period_data.html.twig' %}
{% block period_name %}
<th class="text-center text-nowrap{% if column is weekend %} weekend{% endif %}{% if column is today %} today{% endif %}">
{{ column|date_weekday }}
</th>
{% endblock %}
{% block total_rate_user %}
<a href="{{ path(subReportRoute, {'sumType': dataType, 'date': subReportDate|report_date, 'user': userPeriod.user.id}) }}">{{ usersTotalRate|money }}</a>
{% endblock %}
{% block total_internal_rate_user %}
<a href="{{ path(subReportRoute, {'sumType': dataType, 'date': subReportDate|report_date, 'user': userPeriod.user.id}) }}">{{ usersTotalInternalRate|money }}</a>
{% endblock %}
{% block total_duration_user %}
<a href="{{ path(subReportRoute, {'sumType': dataType, 'date': subReportDate|report_date, 'user': userPeriod.user.id}) }}">{{ usersTotalDuration|duration(decimal) }}</a>
{% endblock %}
{% block rate %}
{{ period.totalRate|money }}
{% endblock %}
{% block internal_rate %}
{{ period.totalInternalRate|money }}
{% endblock %}
{% block duration %}
{{ period.totalDuration|duration(decimal) }}
{% endblock %}
{% block period_cell_class %}{% if period.date is weekend %} weekend{% endif %}{% if period.date is today %} today{% endif %}{% endblock %}
{% endembed %}
{% endif %}
{% endblock %}
{% endembed %}
@@ -34,8 +69,8 @@
{{ parent() }}
<script type="text/javascript">
document.addEventListener('kimai.initialized', function() {
jQuery('#{{ form.date.vars.id }}').on('change', function(ev) {
jQuery(this).closest('form').submit();
jQuery('#user-list-filter-form').on('change', function(ev) {
jQuery(this).submit();
});
});
</script>

View File

@@ -1,69 +0,0 @@
{% set absoluteTotals = 0 %}
{% set totals = {} %}
<table class="table table-bordered table-hover dataTable">
<thead>
<tr>
<th>&nbsp;</th>
<th class="text-center">{{ 'stats.durationTotal'|trans }}</th>
{% for day in stats.0.getDateTimes() %}
<th class="text-center text-nowrap{% if day is weekend %} weekend{% endif %}{% if day is today %} today{% endif %}">
{% block period_name %}
{{ day|date_weekday }}
{% endblock %}
</th>
{% set totals = totals|merge({(day|report_date): 0}) %}
{% endfor %}
</tr>
</thead>
<tbody>
{% for userPeriod in stats %}
{% set usersTotalDuration = 0 %}
<tr class="user">
<td class="text-nowrap">
{% block user_column %}
{% from "macros/widgets.html.twig" import label_dot %}
{{ label_dot(userPeriod.user.displayName, userPeriod.user.color) }}
{% endblock %}
</td>
{% for period in userPeriod.days %}
{% if period.totalDuration > 0 %}
{% set usersTotalDuration = usersTotalDuration + period.totalDuration %}
{% set absoluteTotals = absoluteTotals + period.totalDuration %}
{% endif %}
{% set totals = totals|merge({(period.date|report_date): (totals[period.date|report_date] + period.totalDuration)}) %}
{% endfor %}
<th class="text-nowrap text-center total">
{% block total_duration_user %}
<a href="{{ path(subReportRoute, {'date': subReportDate|report_date, 'user': userPeriod.user.id}) }}">{{ usersTotalDuration|duration(decimal) }}</a>
{% endblock %}
</th>
{% for period in userPeriod.days %}
<td class="text-nowrap text-center day-total{% if period.date is weekend %} weekend{% endif %}{% if period.date is today %} today{% endif %}">
{% if period.totalDuration > 0 %}
{% block duration %}
{{ period.totalDuration|duration(decimal) }}
{% endblock %}
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr class="summary">
<td>{{ 'stats.durationTotal'|trans }}</td>
<td class="text-center text-nowrap">
{% block total_duration %}
{{ absoluteTotals|duration(decimal) }}
{% endblock %}
</td>
{% for id, total in totals %}
<td class="text-center text-nowrap">
{% block total_duration_period %}
{{ total|duration(decimal) }}
{% endblock %}
</td>
{% endfor %}
</tr>
</tfoot>
</table>

View File

@@ -1,20 +1,46 @@
{% embed 'reporting/report_user_list_data.html.twig' %}
{% embed 'reporting/user_list_period_data.html.twig' %}
{% block user_column %}
{{ userPeriod.user.displayName }}
{% endblock %}
{% block duration -%}
=VALUE("{{ period.totalDuration|duration(true) }}")
{%- endblock %}
{% block total_duration -%}
=VALUE("{{ absoluteDuration|duration(true) }}")
{%- endblock %}
{% block total_duration_user -%}
=VALUE("{{ usersTotalDuration|duration(true) }}")
{%- endblock %}
{% block total_duration -%}
=VALUE("{{ absoluteTotals|duration(true) }}")
{%- endblock %}
{% block total_duration_period -%}
=VALUE("{{ total|duration(true) }}")
{%- endblock %}
{% block rate %}
=VALUE("{{ period.totalRate|money }}")
{% endblock %}
{% block total_rate %}
=VALUE("{{ absoluteRate|money }}")
{% endblock %}
{% block total_rate_user %}
=VALUE("{{ usersTotalRate|money }}")
{% endblock %}
{% block total_rate_period %}
=VALUE("{{ total|money }}")
{% endblock %}
{% block internal_rate %}
=VALUE("{{ period.totalInternalRate|money }}")
{% endblock %}
{% block total_internal_rate %}
=VALUE("{{ absoluteInternalRate|money }}")
{% endblock %}
{% block total_internal_rate_user %}
=VALUE("{{ usersTotalInternalRate|money }}")
{% endblock %}
{% block total_internal_rate_period %}
=VALUE("{{ total|money }}")
{% endblock %}
{% block period_name %}
{{ day|date_short }}
<th class="text-center text-nowrap">
{{ column|date_short }}
</th>
{% endblock %}
{% endembed %}

View File

@@ -5,25 +5,74 @@
{% block report %}
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
{% from "macros/widgets.html.twig" import nothing_found, action_button %}
{% from "macros/widgets.html.twig" import nothing_found %}
{% block box_before %}
{{ form_start(form, {'attr': {'class': 'form-inline form-reporting'}}) }}
{{ form_start(form, {'attr': {'class': 'form-inline form-reporting', 'id': 'user-list-filter-form'}}) }}
{% endblock %}
{% block box_after %}
{{ form_end(form) }}
{% endblock %}
{% block box_tools %}
<button class="btn btn-default btn-sm" formaction="{{ path(export_route) }}" type="submit"><i class="{{ 'download'|icon }}"></i></button>
{% endblock %}
{% block box_title %}
{{ form_widget(form.date) }}
{% if form.sumType.vars.choices|length > 1 %}
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="{{ 'display'|icon }}"></i> <span class="caret"></span>
</button>
<ul class="dropdown-menu checkbox-menu">
<li>
{{ form_widget(form.sumType) }}
</li>
</ul>
</div>
{% endif %}
<button class="btn btn-primary" formaction="{{ path(export_route) }}" type="submit"><i class="{{ 'download'|icon }}"></i></button>
{% endblock %}
{% block box_body_class %}{{ box_id }} table-responsive {% if hasData %}no-padding{% endif %}{% endblock %}
{% block box_body %}
{% if not hasData %}
{{ nothing_found() }}
{% else %}
{% embed 'reporting/report_user_list_monthly_data.html.twig' %}{% endembed %}
{% embed 'reporting/user_list_period_data.html.twig' %}
{% block period_name %}
<th class="text-center text-nowrap">
<a href="{{ path('report_monthly_users', {'date': column|report_date, 'sumType': dataType}) }}">
{{ column|month_name }}<br>
{{ column|date_format('Y') }}
</a>
</th>
{% endblock %}
{% block total_rate_user %}
<a href="{{ path('report_user_year', {'sumType': dataType, 'date': create_date(query.date.format('Y') ~'-01-01')|report_date, 'user': userPeriod.user.id}) }}">
{{ usersTotalRate|money }}
</a>
{% endblock %}
{% block total_internal_rate_user %}
<a href="{{ path('report_user_year', {'sumType': dataType, 'date': create_date(query.date.format('Y') ~'-01-01')|report_date, 'user': userPeriod.user.id}) }}">
{{ usersTotalInternalRate|money }}
</a>
{% endblock %}
{% block total_duration_user %}
<a href="{{ path('report_user_year', {'sumType': dataType, 'date': create_date(query.date.format('Y') ~'-01-01')|report_date, 'user': userPeriod.user.id}) }}">
{{ usersTotalDuration|duration(decimal) }}
</a>
{% endblock %}
{% block rate %}
<a href="{{ path('report_user_month', {'sumType': dataType, 'date': create_date(period.date.format('Y') ~'-'~period.date.format('m')~'-01')|report_date, 'user': userPeriod.user.id}) }}" data-toggle="tooltip" title="{{ 'label.billable'|trans }}: {{ period.billableDuration|duration(decimal) }}">
{{ period.totalRate|money }}
</a>
{% endblock %}
{% block internal_rate %}
<a href="{{ path('report_user_month', {'sumType': dataType, 'date': create_date(period.date.format('Y') ~'-'~period.date.format('m')~'-01')|report_date, 'user': userPeriod.user.id}) }}" data-toggle="tooltip" title="{{ 'label.billable'|trans }}: {{ period.billableDuration|duration(decimal) }}">
{{ period.totalInternalRate|money }}
</a>
{% endblock %}
{% block duration %}
<a href="{{ path('report_user_month', {'sumType': dataType, 'date': create_date(period.date.format('Y') ~'-'~period.date.format('m')~'-01')|report_date, 'user': userPeriod.user.id}) }}" data-toggle="tooltip" title="{{ 'label.billable'|trans }}: {{ period.billableDuration|duration(decimal) }}">
{{ period.totalDuration|duration(decimal) }}
</a>
{% endblock %}
{% endembed %}
{% endif %}
{% endblock %}
{% endembed %}
@@ -34,8 +83,8 @@
{{ parent() }}
<script type="text/javascript">
document.addEventListener('kimai.initialized', function() {
jQuery('#{{ form.date.vars.id }}').on('change', function(ev) {
jQuery(this).closest('form').submit();
jQuery('#user-list-filter-form').on('change', function(ev) {
jQuery(this).submit();
});
});
</script>

View File

@@ -1,74 +0,0 @@
{% set absoluteTotals = 0 %}
{% set totals = {} %}
<table class="table table-bordered table-hover dataTable">
<thead>
<tr>
<th>&nbsp;</th>
<th class="text-center">{{ 'stats.durationTotal'|trans }}</th>
{% for month in stats.0.getDateTimes() %}
<th class="text-center text-nowrap">
{% block period_name %}
<a href="{{ path('report_monthly_users', {'date': month|report_date}) }}">
{{ month|month_name }}<br>
{{ month|date_format('Y') }}
</a>
{% endblock %}
</th>
{% set totals = totals|merge({(month|report_date): 0}) %}
{% endfor %}
</tr>
</thead>
<tbody>
{% for userPeriod in stats|filter(row => row.user is not null) %}
{% set usersTotalDuration = 0 %}
<tr class="user">
<td class="text-nowrap">
{% block user_column %}
{% from "macros/widgets.html.twig" import label_dot %}
{{ label_dot(userPeriod.user.displayName, userPeriod.user.color) }}
{% endblock %}
</td>
{% for mid, period in userPeriod.months %}
{% if period.totalDuration > 0 %}
{% set usersTotalDuration = usersTotalDuration + period.totalDuration %}
{% set absoluteTotals = absoluteTotals + period.totalDuration %}
{% endif %}
{% endfor %}
<th class="text-nowrap text-center total">
{% block total_duration_user %}
{{ usersTotalDuration|duration(decimal) }}
{% endblock %}
</th>
{% for mid, period in userPeriod.months %}
<td class="text-nowrap text-center day-total">
{% if period.totalDuration > 0 %}
{% block duration %}
<a href="{{ path('report_user_month', {'date': create_date(period.date.format('Y') ~'-'~period.date.format('m')~'-01')|report_date, 'user': userPeriod.user.id}) }}" data-toggle="tooltip" title="{{ 'label.billable'|trans }}: {{ period.billableDuration|duration(decimal) }}">
{{ period.totalDuration|duration(decimal) }}
</a>
{% endblock %}
{% set totals = totals|merge({(period.date|report_date): (totals[period.date|report_date] + period.totalDuration)}) %}
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr class="summary">
<td>{{ 'stats.durationTotal'|trans }}</td>
<td class="text-center text-nowrap">
{% block total_duration %}
{{ absoluteTotals|duration(decimal) }}
{% endblock %}
</td>
{% for id, total in totals %}
<td class="text-center text-nowrap">
{% block total_duration_period %}
{{ total|duration(decimal) }}
{% endblock %}
</td>
{% endfor %}
</tr>
</tfoot>
</table>

View File

@@ -1,4 +1,4 @@
{% embed 'reporting/report_user_list_monthly_data.html.twig' %}
{% embed 'reporting/user_list_period_data.html.twig' %}
{% block user_column %}
{{ userPeriod.user.displayName }}
{% endblock %}
@@ -9,12 +9,38 @@
=VALUE("{{ usersTotalDuration|duration(true) }}")
{%- endblock %}
{% block total_duration -%}
=VALUE("{{ absoluteTotals|duration(true) }}")
=VALUE("{{ absoluteDuration|duration(true) }}")
{%- endblock %}
{% block total_duration_period -%}
=VALUE("{{ total|duration(true) }}")
{%- endblock %}
{% block rate %}
=VALUE("{{ period.totalRate|money }}")
{% endblock %}
{% block total_rate %}
=VALUE("{{ absoluteRate|money }}")
{% endblock %}
{% block total_rate_user %}
=VALUE("{{ usersTotalRate|money }}")
{% endblock %}
{% block total_rate_period %}
=VALUE("{{ total|money }}")
{% endblock %}
{% block internal_rate %}
=VALUE("{{ period.totalInternalRate|money }}")
{% endblock %}
{% block total_internal_rate %}
=VALUE("{{ absoluteInternalRate|money }}")
{% endblock %}
{% block total_internal_rate_user %}
=VALUE("{{ usersTotalInternalRate|money }}")
{% endblock %}
{% block total_internal_rate_period %}
=VALUE("{{ total|money }}")
{% endblock %}
{% block period_name %}
{{ month|month_name }} {{ month|date_format('Y') }}
<th class="text-center text-nowrap">
{{ column|month_name }} {{ column|date_format('Y') }}
</th>
{% endblock %}
{% endembed %}

View File

@@ -0,0 +1,128 @@
{%- set absoluteDuration = 0 -%}
{%- set absoluteInternalRate = 0 -%}
{%- set absoluteRate = 0 -%}
{%- set totalsDuration = {} -%}
{%- set totalsInternalRate = {} -%}
{%- set totalsRate = {} -%}
{% if dataType == 'rate' %}
{% set dataTypeTitle = 'stats.amountTotal' %}
{% elseif dataType == 'internalRate' %}
{% set dataTypeTitle = 'label.rate_internal' %}
{% else %}
{% set dataTypeTitle = 'stats.durationTotal' %}
{% endif %}
<table class="table table-bordered table-hover dataTable">
<thead>
<tr>
<th>&nbsp;</th>
<th class="text-center reportDataTypeTitle">{{ dataTypeTitle|trans }}</th>
{% for column in stats.0.getDateTimes() %}
{% block period_name %}{% endblock %}
{% set columnKey = column|report_date %}
{% set totalsDuration = totalsDuration|merge({(columnKey): 0}) %}
{% set totalsInternalRate = totalsInternalRate|merge({(columnKey): 0}) %}
{% set totalsRate = totalsRate|merge({(columnKey): 0}) %}
{% endfor %}
</tr>
</thead>
<tbody>
{% for userPeriod in stats|filter(row => row.user is not null) %}
{% set usersTotalDuration = 0 %}
{% set usersTotalInternalRate = 0 %}
{% set usersTotalRate = 0 %}
<tr class="user">
<td class="text-nowrap">
{% block user_column %}
{% from "macros/widgets.html.twig" import label_dot %}
{{ label_dot(userPeriod.user.displayName, userPeriod.user.color) }}
{% endblock %}
</td>
{% for period in attribute(userPeriod, period_attribute) %}
{% if period.totalDuration > 0 %}
{% set usersTotalDuration = usersTotalDuration + period.totalDuration %}
{% set absoluteDuration = absoluteDuration + period.totalDuration %}
{% endif %}
{% if period.totalInternalRate > 0 %}
{% set usersTotalInternalRate = usersTotalInternalRate + period.totalInternalRate %}
{% set absoluteInternalRate = absoluteInternalRate + period.totalInternalRate %}
{% endif %}
{% if period.totalRate > 0 %}
{% set usersTotalRate = usersTotalRate + period.totalRate %}
{% set absoluteRate = absoluteRate + period.totalRate %}
{% endif %}
{% set reportDateKey = period.date|report_date %}
{% set totalsDuration = totalsDuration|merge({(reportDateKey): (totalsDuration[reportDateKey] + period.totalDuration)}) %}
{% 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">
{% if dataType == 'rate' %}
{% block total_rate_user %}{% endblock %}
{% elseif dataType == 'internalRate' %}
{% block total_internal_rate_user %}{% endblock %}
{% else %}
{% block total_duration_user %}{% endblock %}
{% endif %}
</th>
{% for period in attribute(userPeriod, period_attribute) %}
<td class="text-nowrap text-center day-total{% block period_cell_class %}{% endblock %}">
{% if period.totalDuration > 0 or period.totalRate > 0 or period.totalInternalRate > 0 %}
{% if dataType == 'rate' %}
{% block rate %}{% endblock %}
{% elseif dataType == 'internalRate' %}
{% block internal_rate %}{% endblock %}
{% else %}
{% block duration %}{% endblock %}
{% endif %}
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr class="summary">
<td>{{ dataTypeTitle|trans }}</td>
<td class="text-center text-nowrap">
{% if dataType == 'rate' %}
{% block total_rate %}
{{ absoluteRate|money }}
{% endblock %}
{% elseif dataType == 'internalRate' %}
{% block total_internal_rate %}
{{ absoluteInternalRate|money }}
{% endblock %}
{% else %}
{% block total_duration %}
{{ absoluteDuration|duration(decimal) }}
{% endblock %}
{% endif %}
</td>
{% if dataType == 'rate' %}
{% for id, total in totalsRate %}
<td class="text-center text-nowrap">
{% block total_rate_period %}
{{ total|money }}
{% endblock %}
</td>
{% endfor %}
{% elseif dataType == 'internalRate' %}
{% for id, total in totalsInternalRate %}
<td class="text-center text-nowrap">
{% block total_internal_rate_period %}
{{ total|money }}
{% endblock %}
</td>
{% endfor %}
{% else %}
{% for id, total in totalsDuration %}
<td class="text-center text-nowrap">
{% block total_duration_period %}
{{ total|duration(decimal) }}
{% endblock %}
</td>
{% endfor %}
{% endif %}
</tr>
</tfoot>
</table>

View File

@@ -27,7 +27,9 @@
{% endif %}
{% set monthRoute = null %}
{%- if user.enabled and is_granted('view_reporting') and (app.user.id == user.id or is_granted('view_other_timesheet')) -%}
{% set canSeeReport = user.enabled and is_granted('view_reporting') and (app.user.id == user.id or is_granted('view_other_timesheet')) %}
{%- if canSeeReport -%}
{% set monthRoute = path('report_user_month', {'user': user.id, 'date': '__MONTH__'}) %}
{% endif %}
@@ -37,6 +39,11 @@
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
{% import "macros/charts.html.twig" as charts %}
{% block box_title %}{{ year }}{% endblock %}
{% block box_tools %}
{%- if canSeeReport -%}
<a class="btn btn-default btn-sm" href="{{ path('report_user_year', {'user': user.id, 'date': year ~ '-01-01'}) }}"><i class="{{ 'reporting'|icon }}"></i></a>
{% endif %}
{% endblock %}
{% block box_body %}
{% set dataset = [] %}
{% for month in workMonths.year(year) %}