added hourly and money budgets to activity, project and customer (#843)

This commit is contained in:
Kevin Papst
2019-06-11 13:18:57 +02:00
committed by GitHub
parent 833968a87d
commit 5702d7afa8
118 changed files with 1743 additions and 1077 deletions

View File

@@ -0,0 +1,48 @@
{% extends 'base.html.twig' %}
{% import "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'admin_activity.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_activity.subtitle'|trans }}{% endblock %}
{% block page_actions %}{{ actions.activity(activity, 'delete') }}{% endblock %}
{% block main %}
{% set params = {
'%activity%': '<strong>' ~ activity.name ~ '</strong>',
'%project%': '<strong>-</strong>',
'%customer%': '<strong>-</strong>',
'%records%': '<strong>' ~ stats.recordAmount ~ '</strong>',
'%duration%': '<strong>' ~ stats.recordDuration|duration ~ '</strong>'
} %}
{% if activity.project is not null %}
{% set params = params|merge({
'%project%': '<strong>' ~ activity.project.name ~ '</strong>',
'%customer%': '<strong>' ~ activity.project.customer.name ~ '</strong>',
}) %}
{% endif %}
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
{% import "macros/progressbar.html.twig" as progress %}
{% block box_title %}{{ activity.name }}{% endblock %}
{% block box_body %}
<p>
{{ 'admin_activity.short_stats'|trans(params)|raw }}
</p>
{% set currency = null %}
{% if activity.project is not null %}
{% set currency = activity.project.customer.currency %}
{% endif %}
{% if activity.budget > 0 %}
{{ progress.progressbar(activity.budget, stats.recordRate, 'label.budget'|trans, stats.recordRate|money(currency) ~ ' / ' ~ activity.budget|money(currency) ) }}
{% endif %}
{% if activity.timeBudget > 0 %}
{{ progress.progressbar(activity.timeBudget, stats.recordDuration, 'label.timeBudget'|trans, stats.recordDuration|duration ~ ' / ' ~ activity.timeBudget|duration ) }}
{% endif %}
{% endblock %}
{% endembed %}
{% endblock %}

View File

@@ -24,8 +24,10 @@
}) %}
{% endif %}
{% set message = '<p>' ~ ("admin_activity.short_stats"|trans(params)|raw) ~ '</p><p>' ~ ("admin_entity.delete_confirm"|trans|raw) ~ '</p>' %}
{{ include(app.request.xmlHttpRequest ? 'default/_form_delete_modal.html.twig' : 'default/_form_delete.html.twig', {
'message': "admin_activity.delete_confirm"|trans(params)|raw,
'message': message|raw,
'form': form,
'used': inUse,
'back': path('admin_activity')

View File

@@ -109,7 +109,7 @@
{% import "macros/widgets.html.twig" as widgets %}
<li class="dropdown user-menu">
<a href="#" class="dropdown-toggle ddt-large" data-toggle="dropdown">
<i class="{{ 'user'|icon }} fa-2x"></i>
<i class="{{ 'avatar'|icon }} fa-2x"></i>
</a>
<ul class="dropdown-menu">
{% if app.user is not null %}

View File

@@ -0,0 +1,37 @@
{% extends 'base.html.twig' %}
{% import "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'admin_customer.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_customer.subtitle'|trans }}{% endblock %}
{% block page_actions %}{{ actions.customer(customer, 'delete') }}{% endblock %}
{% block main %}
{% set params = {
'%activity%': '<strong>' ~ stats.activityAmount ~ '</strong>',
'%project%': '<strong>' ~ stats.projectAmount ~ '</strong>',
'%customer%': '<strong>' ~ customer.name ~ '</strong>',
'%records%': '<strong>' ~ stats.recordAmount ~ '</strong>',
'%duration%': '<strong>' ~ stats.recordDuration|duration ~ '</strong>',
'%rate%': '<strong>' ~ stats.recordRate|money ~ '</strong>'
} %}
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
{% import "macros/progressbar.html.twig" as progress %}
{% block box_title %}{{ customer.name }}{% endblock %}
{% block box_body %}
<p>
{{ 'admin_customer.short_stats'|trans(params)|raw }}
</p>
{% if customer.budget > 0 %}
{{ progress.progressbar(customer.budget, stats.recordRate, 'label.budget'|trans, stats.recordRate|money(customer.currency) ~ ' / ' ~ customer.budget|money(customer.currency) ) }}
{% endif %}
{% if customer.timeBudget > 0 %}
{{ progress.progressbar(customer.timeBudget, stats.recordDuration, 'label.timeBudget'|trans, stats.recordDuration|duration ~ ' / ' ~ customer.timeBudget|duration ) }}
{% endif %}
{% endblock %}
{% endembed %}
{% endblock %}

View File

@@ -17,8 +17,10 @@
'%duration%': '<strong>' ~ stats.recordDuration|duration ~ '</strong>'
} %}
{% set message = '<p>' ~ ("admin_customer.short_stats"|trans(params)|raw) ~ '</p><p>' ~ ("admin_entity.delete_confirm"|trans|raw) ~ '</p>' %}
{{ include(app.request.xmlHttpRequest ? 'default/_form_delete_modal.html.twig' : 'default/_form_delete.html.twig', {
'message': "admin_customer.delete_confirm"|trans(params)|raw,
'message': message|raw,
'form': form,
'used': inUse,
'back': path('admin_customer')

View File

@@ -9,7 +9,6 @@
'comment': 'hidden-xs',
'country': 'hidden-xs',
'number': 'hidden-xs',
'currency': 'hidden-xs',
'visible': 'hidden-xs',
'actions': 'actions alwaysVisible',
} %}
@@ -38,7 +37,6 @@
<td class="{{ tables.data_table_column_class(tableName, columns, 'comment') }}">{{ entry.comment|comment2html }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'country') }}">{{ entry.country|country }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'number') }}">{{ entry.number }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'currency') }}">{{ entry.currency }} {{ entry.currency|currency }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'visible') }}">{{ widgets.label_visible(entry.visible) }}</td>
<td class="actions">
{{ actions.customer(entry, 'index') }}

View File

@@ -3,7 +3,7 @@
<h3 class="box-title">{{ title|default('confirm.delete'|trans) }}</h3>
</div>
<div class="box-body">
{{ message|default('confirm.delete_message'|trans)|raw }}
{{ message|raw }}
</div>
{{ form_start(form) }}
<div class="box-body">

View File

@@ -12,7 +12,7 @@
{{ form_widget(form) }}
</div>
{% else %}
<p>{{ message|default('confirm.delete_message'|trans)|raw }}</p>
<p>{{ message|raw }}</p>
{{ form_widget(form) }}
{% endif %}
{% endblock %}

View File

@@ -23,6 +23,9 @@
{% endif %}
{% set actions = actions|merge({'edit': {'url': path('admin_activity_edit', {'id': activity.id}), 'class': class}}) %}
{% endif %}
{% if is_granted('budget', activity) %}
{% set actions = actions|merge({'report': {'url': path('admin_activity_budget', {'id': activity.id})}}) %}
{% endif %}
{% if is_granted('view_other_timesheet') %}
{% set actions = actions|merge({'timesheet': path('admin_timesheet', {'customer': activity.project ? activity.project.customer.id : null, 'project': activity.project ? activity.project.id : null, 'activity': activity.id})}) %}
{% endif %}
@@ -35,7 +38,7 @@
{% endif %}
{% if view != 'index' %}
{% set actions = actions|merge({'activity': path('admin_activity')}) %}
{% set actions = actions|merge({'back': path('admin_activity')}) %}
{% endif %}
{% set event = trigger('actions.activity', {'actions': actions, 'view': view, 'activity': activity}) %}
@@ -139,6 +142,9 @@
{% endif %}
{% set actions = actions|merge({'edit': {'url': path('admin_project_edit', {'id': project.id}), 'class': class}}) %}
{% endif %}
{% if is_granted('budget', project) %}
{% set actions = actions|merge({'report': {'url': path('admin_project_budget', {'id': project.id})}}) %}
{% endif %}
{% if is_granted('view_activity') %}
{% set actions = actions|merge({'activity': path('admin_activity', {'customer': project.customer.id, 'project': project.id})}) %}
{% endif %}
@@ -154,7 +160,7 @@
{% endif %}
{% if view != 'index' %}
{% set actions = actions|merge({'project': path('admin_project')}) %}
{% set actions = actions|merge({'back': path('admin_project')}) %}
{% endif %}
{% set event = trigger('actions.project', {'actions': actions, 'view': view, 'project': project}) %}
@@ -189,6 +195,9 @@
{% endif %}
{% set actions = actions|merge({'edit': {'url': path('admin_customer_edit', {'id': customer.id}), 'class': class}}) %}
{% endif %}
{% if is_granted('budget', customer) %}
{% set actions = actions|merge({'report': {'url': path('admin_customer_budget', {'id': customer.id})}}) %}
{% endif %}
{% if is_granted('view_project') %}
{% set actions = actions|merge({'project': path('admin_project', {'customer': customer.id})}) %}
{% endif %}
@@ -207,7 +216,7 @@
{% endif %}
{% if view != 'index' %}
{% set actions = actions|merge({'customer': path('admin_customer')}) %}
{% set actions = actions|merge({'back': path('admin_customer')}) %}
{% endif %}
{% set event = trigger('actions.customer', {'actions': actions, 'view': view, 'customer': customer}) %}
@@ -274,7 +283,7 @@
{% endif %}
{% if view != 'index' %}
{% set actions = actions|merge({'timesheet': path('timesheet')}) %}
{% set actions = actions|merge({'back': path('timesheet')}) %}
{% endif %}
{% set event = trigger('actions.timesheet', {'actions': actions, 'view': view, 'timesheet': timesheet}) %}
@@ -329,7 +338,7 @@
{% endif %}
{% if view != 'index' %}
{% set actions = actions|merge({'timesheet': path('admin_timesheet')}) %}
{% set actions = actions|merge({'back': path('admin_timesheet')}) %}
{% endif %}
{% set event = trigger('actions.timesheet_team', {'actions': actions, 'view': view, 'timesheet': timesheet}) %}

View File

@@ -0,0 +1,28 @@
{% macro progressbar(max, current, title, subTitle) %}
{% set percentReached = (current / (max / 100)) %}
{% set class = "progress-bar-info" %}
{% set width = percentReached|number_format(1, '.', '') %}
{% if percentReached > 90 %}
{% set class = "progress-bar-danger" %}
{% elseif percentReached > 70 %}
{% set class = "progress-bar-warning" %}
{% elseif percentReached > 50 %}
{% set class = "progress-bar-success" %}
{% elseif percentReached > 30 %}
{% set class = "progress-bar-primary" %}
{% endif %}
{% if width > 100 %}
{% set width = 100 %}
{% endif %}
<div class="progress-group">
<span class="progress-text">{{ title }} &ndash; {{ percentReached|number_format(2) }}%</span>
<span class="progress-number">{{ subTitle }}</span>
<div class="progress">
<div class="progress-bar {{ class }}" role="progressbar" aria-valuenow="{{ width }}" aria-valuemin="0" aria-valuemax="100" style="width: {{ width }}%"></div>
</div>
</div>
{% endmacro %}

View File

@@ -0,0 +1,36 @@
{% extends 'base.html.twig' %}
{% import "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'admin_project.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_project.subtitle'|trans }}{% endblock %}
{% block page_actions %}{{ actions.project(project, 'delete') }}{% endblock %}
{% block main %}
{% set params = {
'%project%': '<strong>' ~ project.name ~ '</strong>',
'%customer%': '<strong>' ~ project.customer.name ~ '</strong>',
'%records%': '<strong>' ~ stats.recordAmount ~ '</strong>',
'%activities%': '<strong>' ~ stats.activityAmount ~ '</strong>',
'%duration%': '<strong>' ~ stats.recordDuration|duration ~ '</strong>'
} %}
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
{% import "macros/progressbar.html.twig" as progress %}
{% block box_title %}{{ project.name }}{% endblock %}
{% block box_body %}
<p>
{{ 'admin_project.short_stats'|trans(params)|raw }}
</p>
{% if project.budget > 0 %}
{{ progress.progressbar(project.budget, stats.recordRate, 'label.budget'|trans, stats.recordRate|money(project.customer.currency) ~ ' / ' ~ project.budget|money(project.customer.currency) ) }}
{% endif %}
{% if project.timeBudget > 0 %}
{{ progress.progressbar(project.timeBudget, stats.recordDuration, 'label.timeBudget'|trans, stats.recordDuration|duration ~ ' / ' ~ project.timeBudget|duration ) }}
{% endif %}
{% endblock %}
{% endembed %}
{% endblock %}

View File

@@ -17,8 +17,10 @@
'%duration%': '<strong>' ~ stats.recordDuration|duration ~ '</strong>'
} %}
{% set message = '<p>' ~ ("admin_project.short_stats"|trans(params)|raw) ~ '</p><p>' ~ ("admin_entity.delete_confirm"|trans|raw) ~ '</p>' %}
{{ include(app.request.xmlHttpRequest ? 'default/_form_delete_modal.html.twig' : 'default/_form_delete.html.twig', {
'message': "admin_project.delete_confirm"|trans(params)|raw,
'message': message|raw,
'form': form,
'used': inUse,
'back': path('admin_project')

View File

@@ -8,7 +8,6 @@
'name': 'alwaysVisible',
'customer': 'hidden-xs',
'comment': 'hidden-xs hidden-sm',
'budget': 'hidden-xs',
'visible': '',
'actions': 'actions alwaysVisible',
} %}
@@ -38,7 +37,6 @@
{{ widgets.label_customer(entry.customer, path('admin_customer_edit', {'id' : entry.customer.id})) }}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'comment') }}">{{ entry.comment|comment2html }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'budget') }}">{{ entry.budget|money(entry.customer.currency) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'visible') }}">{{ widgets.label_visible(entry.visible) }}</td>
<td class="actions">
{{ actions.project(entry, 'index') }}

View File

@@ -15,8 +15,10 @@
'%duration%': '<strong>' ~ stats.durationTotal|duration ~ '</strong>'
} %}
{% set message = '<p>' ~ ("admin_user.short_stats"|trans(params)|raw) ~ '</p>' %}
{{ include(app.request.xmlHttpRequest ? 'default/_form_delete_modal.html.twig' : 'default/_form_delete.html.twig', {
'message': "admin_user.delete_confirm"|trans(params)|raw,
'message': message|raw,
'form': form,
'used': inUse,
'back': path('admin_user')

View File

@@ -40,7 +40,9 @@
<td class="{{ tables.data_table_column_class(tableName, columns, 'title') }}">{{ entry.title }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'roles') }}">
{% for role in entry.roles %}
{{ widgets.label_role(role) }}
{% if role != 'ROLE_USER' %}
{{ widgets.label_role(role) }}
{% endif %}
{% endfor %}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'active') }}">{{ widgets.label_visible(entry.enabled) }}</td>