* improved dev fixtures with more diversity, more data, better testcases, user avatars #42 * added customer stats to dashboard, fixed column length for 3 widgets #42 * fixed empty alias - display empty message for new user #42 * unified-ui for "new" toolbar icon #42 * use kimai2_ as database prefix #42 * added customer stats to dashboard, fixed column length for 3 widgets #42 * fix long project/customer names in "currently active" navbar flyout" #42 * added services config for dev environment #42 * added command to run unit tests #42 * added command to run integration tests #42 * added command to run code sniffer #42 * added phpcs and phpunit to composer #42 * created tests directory #42 * fixed code sniffer warnings #42 * added function to switch result type from Pagerfanta to QueryBuilder #42 * dramatically reduced database calls by using custom joined query #42 * added command to install kimai dependencies #42 * added dev:reset command #42
140 lines
5.9 KiB
PHP
140 lines
5.9 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Kimai package.
|
|
*
|
|
* (c) Kevin Papst <kevin@kevinpapst.de>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace AppBundle\Controller;
|
|
|
|
use AppBundle\Entity\User;
|
|
use TimesheetBundle\Entity\Activity;
|
|
use TimesheetBundle\Entity\Customer;
|
|
use TimesheetBundle\Entity\Project;
|
|
use TimesheetBundle\Entity\Timesheet;
|
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
|
|
|
/**
|
|
* Dashboard controller for the admin area.
|
|
*
|
|
* @Route("/dashboard")
|
|
* @Security("has_role('ROLE_USER')")
|
|
*
|
|
* @author Kevin Papst <kevin@kevinpapst.de>
|
|
*/
|
|
class DashboardController extends Controller
|
|
{
|
|
/**
|
|
* @Route("/", defaults={}, name="dashboard")
|
|
* @Method("GET")
|
|
*/
|
|
public function indexAction()
|
|
{
|
|
$user = $this->getUser();
|
|
|
|
$timesheetRepo = $this->getDoctrine()->getRepository(Timesheet::class);
|
|
$timesheetUserStats = $timesheetRepo->getUserStatistics($user);
|
|
$timesheetGlobalStats = $timesheetRepo->getGlobalStatistics();
|
|
|
|
$activityStats = $this->getDoctrine()->getRepository(Activity::class)->getGlobalStatistics();
|
|
$projectStats = $this->getDoctrine()->getRepository(Project::class)->getGlobalStatistics();
|
|
$customerStats = $this->getDoctrine()->getRepository(Customer::class)->getGlobalStatistics();
|
|
$userStats = $this->getDoctrine()->getRepository(User::class)->getGlobalStatistics();
|
|
|
|
return $this->render('dashboard/index.html.twig', [
|
|
'dashboard_widgets' => $this->getWidgets(),
|
|
'timesheetGlobal' => $timesheetGlobalStats,
|
|
'timesheetUser' => $timesheetUserStats,
|
|
'activity' => $activityStats,
|
|
'project' => $projectStats,
|
|
'customer' => $customerStats,
|
|
'user' => $userStats,
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* colors: blue / yellow / purple / green / black
|
|
* icons: bar-chart / line-chart / calendar / clock-o
|
|
*
|
|
* @return array
|
|
*/
|
|
protected function getWidgets()
|
|
{
|
|
// @codingStandardsIgnoreStart
|
|
$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.info_box_counter('stats.activeRecordings', timesheetGlobal.activeCurrently, 'hourglass-o', 'red', path('admin_timesheet', {'state': 1})) }}",
|
|
],
|
|
];
|
|
|
|
$widgets[] = [
|
|
'id' => 'user.stats',
|
|
'header' => '',
|
|
'widgets' => [
|
|
"{{ widgets.info_box_counter('stats.userTotal', user.totalAmount, 'user', 'red') }}",
|
|
"{{ widgets.info_box_counter('stats.userActiveThisMoth', timesheetGlobal.activeThisMonth, 'user', 'yellow') }}",
|
|
"{{ widgets.info_box_counter('stats.userActiveEver', timesheetGlobal.activeTotal, 'user', 'blue') }}",
|
|
],
|
|
];
|
|
|
|
if (!$this->isGranted('ROLE_ADMIN', null)) {
|
|
return $widgets;
|
|
}
|
|
|
|
$widgets[] = [
|
|
'id' => 'admin.stats',
|
|
'header' => 'dashboard.admin',
|
|
'widgets' => [
|
|
"{{ widgets.info_box_more('stats.userTotal', user.totalAmount, ' ', path('admin_user'), 'user') }}",
|
|
"{{ widgets.info_box_more('stats.customerTotal', customer.totalAmount, '', path('admin_customer'), 'users', 'blue') }}",
|
|
"{{ widgets.info_box_more('stats.projectsTotal', project.totalAmount, '', path('admin_project'), 'book', 'yellow') }}",
|
|
"{{ widgets.info_box_more('stats.activitiesTotal', activity.totalAmount, '', path('admin_activity'), 'tasks', 'purple') }}",
|
|
],
|
|
];
|
|
// @codingStandardsIgnoreEnd
|
|
|
|
return $widgets;
|
|
}
|
|
}
|