daily stats in timesheet (#552)
This commit is contained in:
@@ -229,6 +229,11 @@ div.dataTables_scrollHead table.table-bordered {
|
|||||||
}
|
}
|
||||||
|
|
||||||
table.dataTable {
|
table.dataTable {
|
||||||
|
/* summary row, like the timesheet table provides */
|
||||||
|
tr.summary td {
|
||||||
|
font-weight: bold;
|
||||||
|
border-bottom: 1px solid #ccc;
|
||||||
|
}
|
||||||
td {
|
td {
|
||||||
/*
|
/*
|
||||||
Make sure that the action buttons do not line-break if another column takes all available space
|
Make sure that the action buttons do not line-break if another column takes all available space
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"build/app.js": "/build/app.js?19fe460d7c7c857b408b",
|
"build/app.js": "/build/app.js?19fe460d7c7c857b408b",
|
||||||
"build/app.css": "/build/app.css?dcf6ab4e76723f5aacaff45e3ae90cc7",
|
"build/app.css": "/build/app.css?51fa08d868a6a2e03d602ee2df728169",
|
||||||
"build/images/blue@2x.png": "/build/images/blue@2x.png?2694acfd",
|
"build/images/blue@2x.png": "/build/images/blue@2x.png?2694acfd",
|
||||||
"build/images/blue.png": "/build/images/blue.png?96f8a905",
|
"build/images/blue.png": "/build/images/blue.png?96f8a905",
|
||||||
"build/fonts/fa-solid-900.woff2": "/build/fonts/fa-solid-900.woff2?e8a92a29",
|
"build/fonts/fa-solid-900.woff2": "/build/fonts/fa-solid-900.woff2?e8a92a29",
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ class TimesheetController extends AbstractController
|
|||||||
'query' => $query,
|
'query' => $query,
|
||||||
'showFilter' => $form->isSubmitted(),
|
'showFilter' => $form->isSubmitted(),
|
||||||
'toolbarForm' => $form->createView(),
|
'toolbarForm' => $form->createView(),
|
||||||
|
'showSummary' => $this->getUser()->getPreferenceValue('timesheet.daily_stats', false),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ trait TimesheetControllerTrait
|
|||||||
/**
|
/**
|
||||||
* Get a user from the Security Token Storage.
|
* Get a user from the Security Token Storage.
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return User
|
||||||
* @throws \LogicException If SecurityBundle is not available
|
* @throws \LogicException If SecurityBundle is not available
|
||||||
*/
|
*/
|
||||||
abstract protected function getUser();
|
abstract protected function getUser();
|
||||||
|
|||||||
@@ -77,13 +77,6 @@ class UserPreferenceSubscriber implements EventSubscriberInterface
|
|||||||
$enableHourlyRate = true;
|
$enableHourlyRate = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
(new UserPreference())
|
|
||||||
->setName('timezone')
|
|
||||||
->setValue(date_default_timezone_get())
|
|
||||||
->setType(TimezoneType::class),
|
|
||||||
*/
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
(new UserPreference())
|
(new UserPreference())
|
||||||
->setName(UserPreference::HOURLY_RATE)
|
->setName(UserPreference::HOURLY_RATE)
|
||||||
@@ -136,6 +129,11 @@ class UserPreferenceSubscriber implements EventSubscriberInterface
|
|||||||
->setName('login.initial_view')
|
->setName('login.initial_view')
|
||||||
->setValue(InitialViewType::DEFAULT_VIEW)
|
->setValue(InitialViewType::DEFAULT_VIEW)
|
||||||
->setType(InitialViewType::class),
|
->setType(InitialViewType::class),
|
||||||
|
|
||||||
|
(new UserPreference())
|
||||||
|
->setName('timesheet.daily_stats')
|
||||||
|
->setValue(false)
|
||||||
|
->setType(CheckboxType::class),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,10 @@ class Extensions extends \Twig_Extension
|
|||||||
* @var NumberFormatter
|
* @var NumberFormatter
|
||||||
*/
|
*/
|
||||||
protected $numberFormatter;
|
protected $numberFormatter;
|
||||||
|
/**
|
||||||
|
* @var NumberFormatter
|
||||||
|
*/
|
||||||
|
protected $moneyFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var RequestStack
|
* @var RequestStack
|
||||||
@@ -254,18 +258,15 @@ class Extensions extends \Twig_Extension
|
|||||||
|
|
||||||
if ($this->locale !== $locale) {
|
if ($this->locale !== $locale) {
|
||||||
$this->locale = $locale;
|
$this->locale = $locale;
|
||||||
$this->numberFormatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
|
$this->numberFormatter = new NumberFormatter($locale, NumberFormatter::DECIMAL);
|
||||||
|
$this->moneyFormatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);
|
||||||
}
|
}
|
||||||
|
|
||||||
$fractionDigits = Intl::getCurrencyBundle()->getFractionDigits($currency);
|
|
||||||
$amount = round($amount, $fractionDigits);
|
|
||||||
$result = $this->numberFormatter->format($amount);
|
|
||||||
|
|
||||||
if (null !== $currency) {
|
if (null !== $currency) {
|
||||||
$result = $this->numberFormatter->formatCurrency($amount, $currency);
|
return $this->moneyFormatter->formatCurrency($amount, $currency);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $this->numberFormatter->format($amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -69,24 +69,15 @@
|
|||||||
{% endspaceless %}
|
{% endspaceless %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro data_table_header(name, entries, form, collapseClass) %}
|
{% macro data_table_header(name, entries, skipStripped) %}
|
||||||
{% import _self as macro %}
|
{% import _self as macro %}
|
||||||
{{ macro.data_table_column_modal(name, entries) }}
|
{{ macro.data_table_column_modal(name, entries) }}
|
||||||
<div class="box data_table" id="datatable_{{ name }}">
|
<div class="box data_table" id="datatable_{{ name }}">
|
||||||
{% if form %}
|
|
||||||
{% import "macros/toolbar.html.twig" as macro %}
|
|
||||||
{{ macro.toolbar(form, collapseClass) }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<div class="box-body no-padding">
|
<div class="box-body no-padding">
|
||||||
<div class="dataTables_wrapper form-inline dt-bootstrap">
|
<div class="dataTables_wrapper form-inline dt-bootstrap">
|
||||||
<div class="row">
|
|
||||||
<div class="col-sm-6"></div>
|
|
||||||
<div class="col-sm-6"></div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-12">
|
<div class="col-sm-12">
|
||||||
<table class="table table-striped table-hover dataTable" role="grid">
|
<table class="table {% if not skipStripped %}table-striped {% endif %}table-hover dataTable" role="grid">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
{%- for title, class in entries -%}
|
{%- for title, class in entries -%}
|
||||||
|
|||||||
@@ -18,12 +18,7 @@
|
|||||||
<i class="{{ 'stop-small'|icon }} fa-2x"></i>
|
<i class="{{ 'stop-small'|icon }} fa-2x"></i>
|
||||||
</div>
|
</div>
|
||||||
<h4>
|
<h4>
|
||||||
{# TODO find a CSS solution for this #}
|
<span>{{ entry.activity.name }}</span>
|
||||||
{% if entry.activity.name|length > 23 %}
|
|
||||||
{{ entry.activity.name|slice(0,20) }}...
|
|
||||||
{% else %}
|
|
||||||
{{ entry.activity.name }}
|
|
||||||
{% endif %}
|
|
||||||
<small><i class="{{ 'timesheet'|icon }}"></i> {{ entry|duration }}</small>
|
<small><i class="{{ 'timesheet'|icon }}"></i> {{ entry|duration }}</small>
|
||||||
</h4>
|
</h4>
|
||||||
<p>{{ entry.project.name }} ({{ entry.project.customer.name }})</p>
|
<p>{{ entry.project.name }} ({{ entry.project.customer.name }})</p>
|
||||||
|
|||||||
@@ -3,6 +3,28 @@
|
|||||||
{% import "macros/datatables.html.twig" as tables %}
|
{% import "macros/datatables.html.twig" as tables %}
|
||||||
{% import "macros/toolbar.html.twig" as toolbar %}
|
{% import "macros/toolbar.html.twig" as toolbar %}
|
||||||
|
|
||||||
|
{% macro summary(day, duration, dayRates, columns) %}
|
||||||
|
<tr class="summary info">
|
||||||
|
<td class="text-nowrap">{{ day }}</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td class="text-nowrap">{{ duration|duration }}</td>
|
||||||
|
{% if is_granted('view_rate_own_timesheet') %}
|
||||||
|
<td class="text-nowrap">
|
||||||
|
{% for currency, rate in dayRates %}
|
||||||
|
{{ rate|money(currency) }}
|
||||||
|
{% if not loop.last %}
|
||||||
|
<br>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</td>
|
||||||
|
<td colspan="{{ (columns|length) - 5 }}"></td>
|
||||||
|
{% else %}
|
||||||
|
<td colspan="{{ (columns|length) - 4 }}"></td>
|
||||||
|
{% endif %}
|
||||||
|
</tr>
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
{% block page_title %}{{ 'timesheet.title'|trans }}{% endblock %}
|
{% block page_title %}{{ 'timesheet.title'|trans }}{% endblock %}
|
||||||
{% block page_subtitle %}{{ 'timesheet.subtitle'|trans }}{% endblock %}
|
{% block page_subtitle %}{{ 'timesheet.subtitle'|trans }}{% endblock %}
|
||||||
{% block page_actions %}
|
{% block page_actions %}
|
||||||
@@ -23,7 +45,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
|
{% import _self as timesheet %}
|
||||||
{% if entries.count == 0 %}
|
{% if entries.count == 0 %}
|
||||||
{{ widgets.callout('warning', 'error.no_entries_found') }}
|
{{ widgets.callout('warning', 'error.no_entries_found') }}
|
||||||
{% else %}
|
{% else %}
|
||||||
@@ -49,9 +71,22 @@
|
|||||||
|
|
||||||
{% set tableName = 'timesheet' %}
|
{% set tableName = 'timesheet' %}
|
||||||
|
|
||||||
{{ tables.data_table_header(tableName, columns) }}
|
{{ tables.data_table_header(tableName, columns, showSummary) }}
|
||||||
|
|
||||||
|
{% set day = null %}
|
||||||
|
{% set dayDuration = 0 %}
|
||||||
|
{% set dayRate = {} %}
|
||||||
{% for entry in entries %}
|
{% for entry in entries %}
|
||||||
|
{% set customerCurrency = entry.project.customer.currency %}
|
||||||
|
{% if day is same as(null) %}
|
||||||
|
{% set day = entry.begin|date_short %}
|
||||||
|
{% endif %}
|
||||||
|
{% if showSummary and day is not same as(entry.begin|date_short) %}
|
||||||
|
{{ timesheet.summary(day, dayDuration, dayRate, columns) }}
|
||||||
|
{% set day = entry.begin|date_short %}
|
||||||
|
{% set dayDuration = 0 %}
|
||||||
|
{% set dayRate = {} %}
|
||||||
|
{% endif %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'date') }}">{{ entry.begin|date_short }}</td>
|
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'date') }}">{{ entry.begin|date_short }}</td>
|
||||||
|
|
||||||
@@ -103,8 +138,19 @@
|
|||||||
{{ widgets.button_group(actionButtons) }}
|
{{ widgets.button_group(actionButtons) }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
{% if entry.end %}
|
||||||
|
{% if dayRate[customerCurrency] is not defined %}
|
||||||
|
{% set dayRate = dayRate|merge({(customerCurrency): 0}) %}
|
||||||
|
{% endif %}
|
||||||
|
{% set dayRate = dayRate|merge({(customerCurrency): dayRate[customerCurrency] + entry.rate}) %}
|
||||||
|
{% endif %}
|
||||||
|
{% set dayDuration = dayDuration + entry.duration %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if showSummary %}
|
||||||
|
{{ timesheet.summary(day, dayDuration, dayRate, columns) }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{{ tables.data_table_footer(entries, 'timesheet_paginated') }}
|
{{ tables.data_table_footer(entries, 'timesheet_paginated') }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@@ -112,6 +112,15 @@ class ExtensionsTest extends TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testMoneyNull()
|
||||||
|
{
|
||||||
|
$sut = $this->getSut($this->localeEn, 'en');
|
||||||
|
$this->assertEquals('123.75', $sut->money(123.75));
|
||||||
|
|
||||||
|
$sut = $this->getSut($this->localeEn, 'de');
|
||||||
|
$this->assertEquals('123.234,755', $sut->money(123234.7554));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider getMoneyData
|
* @dataProvider getMoneyData
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -412,6 +412,10 @@
|
|||||||
<source>agendaDay</source>
|
<source>agendaDay</source>
|
||||||
<target>Tag</target>
|
<target>Tag</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="label.timesheet.daily_stats">
|
||||||
|
<source>label.timesheet.daily_stats</source>
|
||||||
|
<target>Tägliche Statistiken im Timesheet anzeigen</target>
|
||||||
|
</trans-unit>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
User timesheet calendar
|
User timesheet calendar
|
||||||
|
|||||||
@@ -412,6 +412,10 @@
|
|||||||
<source>agendaDay</source>
|
<source>agendaDay</source>
|
||||||
<target>Day</target>
|
<target>Day</target>
|
||||||
</trans-unit>
|
</trans-unit>
|
||||||
|
<trans-unit id="label.timesheet.daily_stats">
|
||||||
|
<source>label.timesheet.daily_stats</source>
|
||||||
|
<target>Show daily stats in timesheet</target>
|
||||||
|
</trans-unit>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
User timesheet calendar
|
User timesheet calendar
|
||||||
|
|||||||
Reference in New Issue
Block a user