monthly budget, monthly report, unified report calculation (#2684)

This commit is contained in:
Kevin Papst
2021-08-06 18:38:41 +02:00
committed by GitHub
parent 21f785638c
commit cefd747e91
196 changed files with 5031 additions and 2167 deletions

View File

@@ -4,13 +4,6 @@
{% block report %}
{% set hasData = false %}
{% for day in days %}
{% if day.details is not empty %}
{% set hasData = true %}
{% endif %}
{% endfor %}
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% block box_before %}
@@ -27,67 +20,72 @@
{% endif %}
{{ form_widget(form.date) }}
{% endblock %}
{% block box_body_class %}{{ box_id }} table-responsive{% if hasData %} no-padding{% endif %}{% endblock %}
{% block box_body_class %}{{ box_id }} table-responsive no-padding{% endblock %}
{% block box_body %}
{% if not hasData %}
{{ widgets.nothing_found() }}
{% else %}
{% set totals = {'totals': 0} %}
{% set columns = 2 %}
<table class="table table-bordered table-hover dataTable">
<tr>
<th>&nbsp;</th>
<th>&nbsp;</th>
{% for day in days %}
<th class="text-center text-nowrap{% if day.day is weekend %} weekend{% endif %}">
{{ day.day|day_name(true) }}<br>
{{ day.day|format_date('short') }}
</th>
{% for day in days.dateTimes %}
<th class="text-center text-nowrap{% if day is weekend %} weekend{% endif %}">
{{ day|day_name(true) }}<br>
{{ day|format_date('short') }}
</th>
{% set columns = columns + 1 %}
{% set totals = totals|merge({(day|report_date): 0}) %}
{% endfor %}
</tr>
{% for project in rows %}
{% 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 %}
{% for day in project.days.days %}
<td class="text-nowrap text-center day-total{% if day.date is weekend %} weekend{% 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 %}
<td class="text-nowrap text-center day-total{% if day.date is weekend %} weekend{% endif %}">
{% if day.duration > 0 %}
{{ day.duration|duration }}
{% endif %}
<tr class="activity">
<td class="text-nowrap">
{{ widgets.label_activity(activity.activity) }}
</td>
{% endfor %}
</tr>
<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.duration > 0 %}
{{ day.duration|duration }}
{% endif %}
</td>
{% endfor %}
</tr>
{% endfor %}
{% endfor %}
{% set total = 0 %}
<tr class="summary">
{% for day in days %}
{% set total = total + day.totalDuration %}
{% endfor %}
<th></th>
<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 %}">
{{ day.totalDuration|duration }}
<th class="text-nowrap text-center total">{{ totals['totals']|duration }}</th>
{% for day in days.dateTimes %}
<th class="text-nowrap text-center day-total{% if day is weekend %} weekend{% endif %}">
{{ totals[day|report_date]|duration }}
</th>
{% endfor %}
</tr>
</table>
{% endif %}
{% endblock %}
{% endembed %}
@@ -98,12 +96,12 @@
<script type="text/javascript">
document.addEventListener('kimai.initialized', function() {
{% if form.user is defined %}
$('#{{ form.user.vars.id }}').on('change', function(ev) {
$(this).closest('form').submit();
jQuery('#{{ form.user.vars.id }}').on('change', function(ev) {
jQuery(this).closest('form').submit();
});
{% endif %}
$('#{{ form.date.vars.id }}').on('change', function(ev) {
$(this).closest('form').submit();
jQuery('#{{ form.date.vars.id }}').on('change', function(ev) {
jQuery(this).closest('form').submit();
});
});
</script>