diff --git a/app/Resources/translations/messages.de.xliff b/app/Resources/translations/messages.de.xliff
index b045dc55..c18c4c69 100644
--- a/app/Resources/translations/messages.de.xliff
+++ b/app/Resources/translations/messages.de.xliff
@@ -527,6 +527,34 @@
Umsatz total
+
+
+ stats.userTotal
+ Anzahl Benutzer
+
+
+ stats.userActiveThisMoth
+ Aktive Benutzer diesen Monat
+
+
+ stats.userActiveEver
+ Aktive Benutzer jemals
+
+
+ stats.userActiveNow
+ Momentan aktiv
+
+
+ stats.activitiesTotal
+ Anzahl Aktivitäten
+
+
+ stats.projectsTotal
+ Anzahl Projekte
+
+
diff --git a/app/Resources/views/dashboard/index.html.twig b/app/Resources/views/dashboard/index.html.twig
index 4452d16e..42ba2eba 100644
--- a/app/Resources/views/dashboard/index.html.twig
+++ b/app/Resources/views/dashboard/index.html.twig
@@ -6,98 +6,23 @@
{% block main %}
- {# FIXME Übersetzungen hinzufügen #}
-
{# blue / yellow / purple / green / black #}
{# bar-chart / line-chart / calendar / clock-o #}
- {#
-
-
- {{ widgets.info_box_counter('stats.durationThisMonth', timesheetUser.durationThisMonth|duration(true), 'hourglass-o', 'green') }}
-
-
- {{ widgets.info_box_counter('stats.amountThisMonth', timesheetUser.amountThisMonth|money, 'money', 'blue') }}
-
-
- {{ widgets.info_box_counter('stats.durationTotal', timesheetUser.durationTotal|duration(true), 'hourglass-o', 'red') }}
-
-
- {{ widgets.info_box_counter('stats.amountTotal', timesheetUser.amountTotal|money, 'money', 'yellow') }}
+ {% for widgetTemplate in settings.widgets %}
+
+ {% set widgetString = '{% import "macros/widgets.html.twig" as widgets %}' ~ widgetTemplate %}
+ {{ include(template_from_string(widgetString)) }}
+ {% endfor %}
- {% endif %}
-
- {% if is_granted('ROLE_TEAMLEAD') %}
- {{ widgets.page_header('dashboard.all') }}
-
-
- {{ widgets.info_box_counter('Arbeitszeit diesen Monat', timesheetGlobal.durationThisMonth|duration(true), 'hourglass-o', 'blue') }}
-
-
- {{ widgets.info_box_counter('Umsatz diesen Monat', timesheetGlobal.amountThisMonth|money, 'money', 'green') }}
-
-
- {{ widgets.info_box_counter('Arbeitszeit total', timesheetGlobal.durationTotal|duration(true), 'hourglass-o', 'yellow') }}
-
-
- {{ widgets.info_box_counter('Umsatz total', timesheetGlobal.amountTotal|money, 'money', 'red') }}
-
-
- {% endif %}
-
- {% if is_granted('ROLE_TEAMLEAD') %}
-
-
- {{ widgets.info_box_counter('Anzahl Benutzer', user.totalAmount, 'users', 'red') }}
-
-
- {{ widgets.info_box_counter('Aktive Benutzer diesen Monat', timesheetGlobal.activeThisMonth, 'users', 'yellow') }}
-
-
- {{ widgets.info_box_counter('Aktive Benutzer jemals', timesheetGlobal.activeTotal, 'users', 'blue') }}
-
-
- {{ widgets.info_box_counter('Momentan aktiv', timesheetGlobal.activeCurrently, 'users', 'green') }}
-
-
- {% endif %}
-
- {% if is_granted('ROLE_ADMIN') %}
- {{ widgets.page_header('dashboard.admin') }}
-
-
- {{ widgets.info_box_more('Anzahl Aktivitäten', activity.totalAmount, '', path('admin_activity'), 'tasks', 'purple') }}
-
-
- {{ widgets.info_box_more('Anzahl Projekte', project.totalAmount, '', path('admin_project'), 'book', 'yellow') }}
-
-
- {{ widgets.info_box_more('Anzahl Benutzer', user.totalAmount, ' ', path('admin_user'), 'users') }}
-
-
- {# FIXME #}
- {{ widgets.info_box_more('Momentan aktiv', timesheetGlobal.activeCurrently, '', '#', 'hourglass-o', 'red') }}
-
-
-
- {% endif %}
+ {% endfor %}
{% endblock %}
diff --git a/app/config/services.yml b/app/config/services.yml
index f0ba9c2b..681ca506 100644
--- a/app/config/services.yml
+++ b/app/config/services.yml
@@ -11,6 +11,12 @@ services:
tags:
- { name: twig.extension }
+ # twig function: template_from_string()
+ app.twig.loader_extension:
+ class: Twig_Extension_StringLoader
+ tags:
+ - { name: 'twig.extension' }
+
app.twig.intl_extension:
public: false
class: Twig_Extensions_Extension_Intl
diff --git a/src/AppBundle/Controller/DashboardController.php b/src/AppBundle/Controller/DashboardController.php
index 1eef0c71..0f478f27 100644
--- a/src/AppBundle/Controller/DashboardController.php
+++ b/src/AppBundle/Controller/DashboardController.php
@@ -12,6 +12,7 @@
namespace AppBundle\Controller;
use AppBundle\Entity\User;
+use AppBundle\Model\UserStatistic;
use TimesheetBundle\Entity\Activity;
use TimesheetBundle\Entity\Project;
use TimesheetBundle\Entity\Timesheet;
@@ -19,7 +20,10 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
-use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
+use TimesheetBundle\Model\ActivityStatistic;
+use TimesheetBundle\Model\ProjectStatistic;
+use TimesheetBundle\Model\TimesheetGlobalStatistic;
+use TimesheetBundle\Model\TimesheetStatistic;
/**
* Dashboard controller for the admin area.
@@ -48,6 +52,7 @@ class DashboardController extends Controller
$userStats = $this->getDoctrine()->getRepository(User::class)->getGlobalStatistics();
return $this->render('dashboard/index.html.twig', [
+ 'dashboard_widgets' => $this->getWidgets($timesheetUserStats, $timesheetGlobalStats, $activityStats, $projectStats, $userStats),
'timesheetGlobal' => $timesheetGlobalStats,
'timesheetUser' => $timesheetUserStats,
'activity' => $activityStats,
@@ -55,4 +60,79 @@ class DashboardController extends Controller
'user' => $userStats,
]);
}
+
+ protected function getWidgets(
+ TimesheetStatistic $timesheetUserStats,
+ TimesheetGlobalStatistic $timesheetGlobalStats,
+ ActivityStatistic $activityStats,
+ ProjectStatistic $projectStats,
+ UserStatistic $userStats
+ ) {
+ $widgets = [
+ /*
+ [
+ 'header' => 'dashboard.you',
+ 'widgets' => [
+ "{{ widgets.info_box_progress('Bewilligte Stunden', 'Stunden zur Abrechnung bewilligt', 120, 10, 'star-o') }}",
+ "{{ widgets.info_box_progress('Umsatz / Monat', '70% Increase in 30 Days', 6830, 30, 'credit-card', 'black') }}",
+ "{{ widgets.info_box_progress('Stunden persönlich', 'Das ist noch nicht genug', 135, 60, 'hourglass-o') }}",
+ "{{ widgets.info_box_progress('Anzahl Benutzer', 'Mehr ist besser!', 5, 90, 'user') }}",
+ ],
+ ],
+ */
+ [
+ 'id' => 'profile.stats',
+ 'header' => 'dashboard.you',
+ 'widgets' => [
+ "{{ widgets.info_box_counter('stats.durationThisMonth', timesheetUser.durationThisMonth|duration(true), 'hourglass-o', 'green') }}",
+ //"{{ widgets.info_box_counter('stats.amountThisMonth', timesheetUser.amountThisMonth|money, 'money', 'blue') }}",
+ "{{ widgets.info_box_counter('stats.durationTotal', timesheetUser.durationTotal|duration(true), 'hourglass-o', 'red') }}",
+ //"{{ widgets.info_box_counter('stats.amountTotal', timesheetUser.amountTotal|money, 'money', 'yellow') }}",
+ ],
+ ],
+ ];
+
+ if (!$this->isGranted('ROLE_TEAMLEAD', null)) {
+ return $widgets;
+ }
+
+ $widgets[] = [
+ 'id' => 'alluser.stats',
+ 'header' => 'dashboard.all',
+ 'widgets' => [
+ "{{ widgets.info_box_counter('stats.durationThisMonth', timesheetGlobal.durationThisMonth|duration(true), 'hourglass-o', 'blue') }}",
+ //"{{ widgets.info_box_counter('stats.amountThisMonth', timesheetGlobal.amountThisMonth|money, 'money', 'green') }}",
+ "{{ widgets.info_box_counter('stats.durationTotal', timesheetGlobal.durationTotal|duration(true), 'hourglass-o', 'yellow') }}",
+ //"{{ widgets.info_box_counter('stats.amountTotal', timesheetGlobal.amountTotal|money, 'money', 'red') }}",
+ ],
+ ];
+
+ $widgets[] = [
+ 'id' => 'user.stats',
+ 'header' => '',
+ 'widgets' => [
+ "{{ widgets.info_box_counter('stats.userTotal', user.totalAmount, 'users', 'red') }}",
+ "{{ widgets.info_box_counter('stats.userActiveThisMoth', timesheetGlobal.activeThisMonth, 'users', 'yellow') }}",
+ "{{ widgets.info_box_counter('stats.userActiveEver', timesheetGlobal.activeTotal, 'users', 'blue') }}",
+ "{{ widgets.info_box_counter('stats.userActiveNow', timesheetGlobal.activeCurrently, 'users', 'green') }}",
+ ],
+ ];
+
+ if (!$this->isGranted('ROLE_ADMIN', null)) {
+ return $widgets;
+ }
+
+ $widgets[] = [
+ 'id' => 'admin.stats',
+ 'header' => 'dashboard.admin',
+ 'widgets' => [
+ "{{ widgets.info_box_more('stats.activitiesTotal', activity.totalAmount, '', path('admin_activity'), 'tasks', 'purple') }}",
+ "{{ widgets.info_box_more('stats.projectsTotal', project.totalAmount, '', path('admin_project'), 'book', 'yellow') }}",
+ "{{ widgets.info_box_more('stats.userTotal', user.totalAmount, ' ', path('admin_user'), 'users') }}",
+ "{{ widgets.info_box_more('stats.userActiveNow', timesheetGlobal.activeCurrently, '', path('admin_timesheet', {'state': 1}), 'hourglass-o', 'red') }}", // FIXME ???
+ ],
+ ];
+
+ return $widgets;
+ }
}
diff --git a/src/AppBundle/Repository/UserRepository.php b/src/AppBundle/Repository/UserRepository.php
index 82e11bc3..b0afdd97 100644
--- a/src/AppBundle/Repository/UserRepository.php
+++ b/src/AppBundle/Repository/UserRepository.php
@@ -29,6 +29,7 @@ class UserRepository extends EntityRepository
* Return statistic data for all user.
*
* @return UserStatistic
+ * @throws \Doctrine\ORM\NonUniqueResultException
*/
public function getGlobalStatistics()
{
diff --git a/src/TimesheetBundle/Repository/ProjectRepository.php b/src/TimesheetBundle/Repository/ProjectRepository.php
index da94fdf3..165bbd5b 100644
--- a/src/TimesheetBundle/Repository/ProjectRepository.php
+++ b/src/TimesheetBundle/Repository/ProjectRepository.php
@@ -40,6 +40,7 @@ class ProjectRepository extends EntityRepository
* Return statistic data for all user.
*
* @return ProjectStatistic
+ * @throws \Doctrine\ORM\NonUniqueResultException
*/
public function getGlobalStatistics()
{