financial year setting + new users working time per year report (#2547)

This commit is contained in:
Kevin Papst
2021-05-14 18:40:48 +02:00
committed by GitHub
parent a9da5f8476
commit f7aa3c1e13
59 changed files with 1690 additions and 217 deletions

View File

@@ -200,7 +200,7 @@
<li>
<a href="{{ path('user_profile', {'username' : app.user.username}) }}">
<h4 class="control-sidebar-subheading">
<i class="{{ 'avatar'|icon }}"></i>
<i class="{{ 'user'|icon }}"></i>
{{ 'my.profile'|trans }}
</h4>
</a>

View File

@@ -71,6 +71,27 @@
{% endif %}
{%- endblock text_widget %}
{% block yearpicker_widget -%}
<div class="btn-group">
<a class="btn btn-default btn-left" href="#" onclick="$('#{{ form.vars.id }}').val('{{ previousYear|date_short }}').change()" data-toggle="tooltip" data-placement="top" title="{{ previousYear|date_short }}">
<i class="{{ 'left'|icon }}"></i>
</a>
<a class="btn btn-default" href="#" onclick="return false;">
<span id="{{ form.vars.id }}_month_name">
{% if show_range %}
{{ year|date_short }} &ndash; {{ nextYear|date_short }}
{% else %}
{{ year|date_format('Y') }}
{% endif %}
</span>
</a>
<a class="btn btn-default btn-right" href="#" onclick="$('#{{ form.vars.id }}').val('{{ nextYear|date_short }}').change()" data-toggle="tooltip" data-placement="top" title="{{ nextYear|date_short }}">
<i class="{{ 'right'|icon }}"></i>
</a>
</div>
{{ block('hidden_widget') }}
{%- endblock yearpicker_widget %}
{% block monthpicker_widget -%}
<div class="btn-group">
<a class="btn btn-default btn-left" href="#" onclick="$('#{{ form.vars.id }}').val('{{ previousMonth|date_short }}').change()" data-toggle="tooltip" data-placement="top" title="{{ previousMonth|month_name(true) }}">

View File

@@ -82,9 +82,7 @@
<th class="text-nowrap text-center total">{{ total|duration }}</th>
{% for day in days %}
<th class="text-nowrap text-center day-total{% if day.day is weekend %} weekend{% endif %}">
{% if day.totalDuration > 0 %}
{{ day.totalDuration|duration }}
{% endif %}
{{ day.totalDuration|duration }}
</th>
{% endfor %}
</tr>

View File

@@ -17,6 +17,7 @@
{% endblock %}
{% block box_body_class %}{{ box_id }} table-responsive no-padding{% endblock %}
{% block box_body %}
{% set absoluteTotals = 0 %}
<table class="table table-bordered table-hover dataTable">
<tr>
<th>&nbsp;</th>
@@ -37,15 +38,14 @@
{% for day in userDay.days %}
{% if day.totalDuration > 0 %}
{% set usersTotalDuration = usersTotalDuration + day.totalDuration %}
{% set absoluteTotals = absoluteTotals + day.totalDuration %}
{% endif %}
{% endfor %}
<th class="text-nowrap text-center total">
{% if usersTotalDuration > 0 %}
{{ usersTotalDuration|duration }}
{% endif %}
{{ usersTotalDuration|duration }}
</th>
{% for day in userDay.days %}
<td class="text-nowrap day-total{% if day.day is weekend %} weekend{% endif %}">
<td class="text-nowrap text-center day-total{% if day.day is weekend %} weekend{% endif %}">
{% if day.totalDuration > 0 %}
{{ day.totalDuration|duration }}
{% endif %}
@@ -53,6 +53,17 @@
{% endfor %}
</tr>
{% endfor %}
<tr>
<th>&nbsp;</th>
<th class="text-center text-nowrap">
{{ absoluteTotals|duration }}
</th>
{% for id, duration in totals %}
<th class="text-center text-nowrap">
{{ duration|duration }}
</th>
{% endfor %}
</tr>
</table>
{% endblock %}
{% endembed %}

View File

@@ -0,0 +1,86 @@
{% 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'}}) }}
{% endblock %}
{% block box_after %}
{{ form_end(form) }}
{% endblock %}
{% block box_title %}
{{ form_widget(form.date) }}
{% endblock %}
{% block box_body_class %}{{ box_id }} table-responsive no-padding{% endblock %}
{% block box_body %}
<table class="table table-bordered table-hover dataTable">
<tr>
<th>&nbsp;</th>
<th>&nbsp;</th>
{% for id, month in months %}
<th class="text-center text-nowrap">
<a href="{{ path('report_monthly_users', {'date': month|date_short}) }}">
{{ month|month_name }}<br>
{{ month|date_format('Y') }}
</a>
</th>
{% endfor %}
</tr>
{% for userYear in rows %}
{% set usersTotalDuration = 0 %}
<tr class="user">
<td class="text-nowrap">
<strong>{{ widgets.username(userYear.user) }}</strong>
</td>
{% for yid, year in userYear.years %}
{% for mid, month in year.months %}
{% if month.totalDuration > 0 %}
{% set usersTotalDuration = usersTotalDuration + month.totalDuration %}
{% endif %}
{% endfor %}
{% endfor %}
<th class="text-nowrap text-center total">
{{ usersTotalDuration|duration }}
</th>
{% for yid, year in userYear.years %}
{% for mid, month in year.months %}
<td class="text-nowrap text-center day-total">
{% if month.totalDuration > 0 %}
<a href="{{ path('report_user_month', {'date': (year.year ~'-'~month.month~'-01')|date_short, 'user': userYear.user.id}) }}" data-toggle="tooltip" title="{{ 'label.billable'|trans }}: {{ month.billableDuration|duration }}">
{{ month.totalDuration|duration }}
</a>
{% endif %}
</td>
{% endfor %}
{% endfor %}
</tr>
{% endfor %}
<tr>
<th>&nbsp;</th>
<th>&nbsp;</th>
{% for id, duration in totals %}
<th class="text-center text-nowrap">
{{ duration|duration }}
</th>
{% endfor %}
</tr>
</table>
{% endblock %}
{% endembed %}
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script type="text/javascript">
document.addEventListener('kimai.initialized', function() {
$('#{{ form.date.vars.id }}').on('change', function(ev) {
$(this).closest('form').submit();
});
});
</script>
{% endblock %}

View File

@@ -28,7 +28,6 @@
{% block page_title %}{{ 'admin_user.title'|trans }}{% endblock %}
{% block page_search %}{{ search.searchModal(toolbarForm) }}{% endblock %}
{% block page_actions %}{{ actions.users('index') }}{% endblock %}
{% block page_icon %}{{ 'user'|icon }}{% endblock %}
{% block main_before %}
{{ tables.data_table_column_modal(tableName, columns, 'kimai.userUpdate') }}

View File

@@ -4,7 +4,6 @@
{% block page_title %}{{ 'admin_user.title'|trans }}{% endblock %}
{% block page_actions %}{{ actions.user(user, tab) }}{% endblock %}
{% block page_icon %}{{ 'user'|icon }}{% endblock %}
{% block main %}
<div class="row">

View File

@@ -82,7 +82,7 @@
}
</script>
{% for year,yearStat in years %}
{% for year, yearStat in years %}
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
{% block box_title %}{{ year }}{% endblock %}
@@ -100,21 +100,33 @@
backgroundColor: '{{ kimai_context.chart.background_color }}',
borderColor: '{{ kimai_context.chart.border_color }}',
data: [
{% for month in yearStat.months %}
{{ (month.totalDuration / 3600)|number_format(2, '.', '') }}
{% if not loop.last %},{% endif %}
{% for monthNumber in 1..12 %}
{% set duration = 0 %}
{% set month = yearStat.month(monthNumber) %}
{% if month is not null %}
{% set duration = month.totalDuration %}
{% endif %}
{{ (duration / 3600)|number_format(2, '.', '') }}
{% if not loop.last %},{% endif %}
{% endfor %}
],
realData: [
{% for month in yearStat.months %}
{% set realDayData = {duration: month.totalDuration|duration, billable: month.billableDuration|duration} %}
{% for monthNumber in 1..12 %}
{% set duration = 0 %}
{% set billable = 0 %}
{% set month = yearStat.month(monthNumber) %}
{% if month is not null %}
{% set duration = month.totalDuration %}
{% set billable = month.billableDuration %}
{% endif %}
{% set realDayData = {'duration': duration|duration, 'billable': billable|duration} %}
{{ realDayData|json_encode|raw }}
{% if not loop.last %},{% endif %}
{% endfor %}
],
monthData: [
{% for month in yearStat.months %}
'{{ yearStat.year }}-{{ month.month|length == 1 ? '0'~ month.month : month.month }}-01'
{% for monthNumber in 1..12 %}
'{{ yearStat.year }}-{{ monthNumber < 10 ? '0' ~ monthNumber : monthNumber }}-01'
{% if not loop.last %},{% endif %}
{% endfor %}
],

View File

@@ -56,12 +56,21 @@
<span class="description-text">{{ 'stats.workingTimeMonth'|trans({'%month%': data.thisMonth|month_name, '%year%': data.thisMonth|date_format('Y')}) }}</span>
</div>
</div>
{% if data.financial is not null %}
<div class="col-sm-3 col-xs-6">
<div class="description-block border-right">
<h5 class="description-header">{{ data.financial|duration }}</h5>
<span class="description-text">{{ 'stats.workingTimeFinancialYear'|trans }}</span>
</div>
</div>
{% else %}
<div class="col-sm-3 col-xs-6">
<div class="description-block border-right">
<h5 class="description-header">{{ data.year|duration }}</h5>
<span class="description-text">{{ 'stats.workingTimeYear'|trans({'%year%': data.thisMonth|date_format('Y')}) }}</span>
</div>
</div>
{% endif %}
</div>
{% endblock %}
{% endembed %}