improvements

This commit is contained in:
Kevin Papst
2016-10-24 00:06:46 +02:00
parent 8940b766b6
commit b72fd888b1
18 changed files with 514 additions and 258 deletions

View File

@@ -0,0 +1,45 @@
<?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 TimesheetBundle\Controller\Admin;
use TimesheetBundle\Entity\Activity;
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;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
/**
* Controller used to manage activities in the admin part of the site.
*
* @Route("/admin/activity")
* @Security("has_role('ROLE_ADMIN')")
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class ActivityController extends Controller
{
/**
* @Route("/", defaults={"page": 1}, name="admin_activity")
* @Route("/page/{page}", requirements={"page": "[1-9]\d*"}, name="admin_activity_paginated")
* @Method("GET")
* @Cache(smaxage="10")
*/
public function indexAction($page)
{
/* @var $entries Pagerfanta */
$entries = $this->getDoctrine()->getRepository(Activity::class)->findAll($page);
return $this->render('TimesheetBundle:admin:activity.html.twig', ['entries' => $entries]);
}
}

View File

@@ -0,0 +1,46 @@
<?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 TimesheetBundle\Controller\Admin;
use Pagerfanta\Pagerfanta;
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;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
/**
* Controller used to manage projects in the admin part of the site.
*
* @Route("/admin/project")
* @Security("has_role('ROLE_ADMIN')")
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class ProjectController extends Controller
{
/**
* @Route("/", defaults={"page": 1}, name="admin_project")
* @Route("/page/{page}", requirements={"page": "[1-9]\d*"}, name="admin_project_paginated")
* @Method("GET")
* @Cache(smaxage="10")
*/
public function indexAction($page)
{
/* @var $entries Pagerfanta */
$entries = $this->getDoctrine()->getRepository(Project::class)->findAll($page);
return $this->render('TimesheetBundle:admin:project.html.twig', ['entries' => $entries]);
}
}

View File

@@ -22,22 +22,23 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
* Controller used for manage timesheet entries in the admin part of the site.
*
* @Route("/admin/timesheet")
* @Security("has_role('ROLE_CUSTOMER')")
* @Security("has_role('ROLE_ADMIN')")
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
class TimesheetController extends Controller
{
/**
* @Route("/", defaults={"page": 1}, name="admin_timesheet_index")
* @Route("/timesheet/{page}", requirements={"page": "[1-9]\d*"}, name="admin_timesheet_index_paginated")
* @Route("/", defaults={"page": 1}, name="admin_timesheet")
* @Route("/page/{page}", requirements={"page": "[1-9]\d*"}, name="admin_timesheet_paginated")
* @Method("GET")
* @Cache(smaxage="10")
*/
public function indexAction($page)
{
/* @var $entries Pagerfanta */
$entries = $this->getDoctrine()->getRepository(Timesheet::class)->findAll($page);
return $this->render('TimesheetBundle:timesheet:index.html.twig', ['entries' => $entries]);
return $this->render('TimesheetBundle:admin:timesheet.html.twig', ['entries' => $entries]);
}
}

View File

@@ -22,7 +22,7 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
* Controller used to manage timesheet contents in the public part of the site.
*
* @Route("/timesheet")
* @Security("has_role('ROLE_CUSTOMER')")
* @Security("has_role('ROLE_USER')")
*
* @author Kevin Papst <kevin@kevinpapst.de>
*/
@@ -37,6 +37,7 @@ class TimesheetController extends Controller
public function indexAction($page)
{
$user = $this->getUser();
/* @var $entries Pagerfanta */
$entries = $this->getDoctrine()->getRepository(Timesheet::class)->findLatest($user, $page);
return $this->render('TimesheetBundle:timesheet:index.html.twig', ['entries' => $entries]);