100 lines
3.3 KiB
PHP
100 lines
3.3 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Kimai time-tracking app.
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace App\Controller;
|
|
|
|
use App\Entity\Timesheet;
|
|
use App\Event\TimesheetMetaDisplayEvent;
|
|
use App\Repository\ActivityRepository;
|
|
use App\Repository\ProjectRepository;
|
|
use App\Repository\TagRepository;
|
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Routing\Annotation\Route;
|
|
|
|
/**
|
|
* @Route(path="/timesheet")
|
|
* @Security("is_granted('view_own_timesheet')")
|
|
*/
|
|
class TimesheetController extends TimesheetAbstractController
|
|
{
|
|
/**
|
|
* @Route(path="/", defaults={"page": 1}, name="timesheet", methods={"GET"})
|
|
* @Route(path="/page/{page}", requirements={"page": "[1-9]\d*"}, name="timesheet_paginated", methods={"GET"})
|
|
* @Security("is_granted('view_own_timesheet')")
|
|
*
|
|
* @param int $page
|
|
* @param Request $request
|
|
* @return Response
|
|
*/
|
|
public function indexAction($page, Request $request)
|
|
{
|
|
return $this->index($page, $request, 'timesheet/index.html.twig', TimesheetMetaDisplayEvent::TIMESHEET);
|
|
}
|
|
|
|
/**
|
|
* @Route(path="/export/{exporter}", name="timesheet_export", methods={"GET"})
|
|
* @Security("is_granted('export_own_timesheet')")
|
|
*
|
|
* @param Request $request
|
|
* @param string $exporter
|
|
* @return Response
|
|
*/
|
|
public function exportAction(Request $request, string $exporter)
|
|
{
|
|
return $this->export($request, $exporter);
|
|
}
|
|
|
|
/**
|
|
* @Route(path="/{id}/edit", name="timesheet_edit", methods={"GET", "POST"})
|
|
* @Security("is_granted('edit', entry)")
|
|
*
|
|
* @param Timesheet $entry
|
|
* @param Request $request
|
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
|
*/
|
|
public function editAction(Timesheet $entry, Request $request)
|
|
{
|
|
return $this->edit($entry, $request, 'timesheet/edit.html.twig');
|
|
}
|
|
|
|
/**
|
|
* @Route(path="/multi-update", name="timesheet_multi_update", methods={"POST"})
|
|
* @Security("is_granted('edit_own_timesheet')")
|
|
*/
|
|
public function multiUpdateAction(Request $request)
|
|
{
|
|
return $this->multiUpdate($request, 'timesheet/multi-update.html.twig');
|
|
}
|
|
|
|
/**
|
|
* @Route(path="/multi-delete", name="timesheet_multi_delete", methods={"POST"})
|
|
* @Security("is_granted('delete_own_timesheet')")
|
|
*/
|
|
public function multiDeleteAction(Request $request)
|
|
{
|
|
return $this->multiDelete($request);
|
|
}
|
|
|
|
/**
|
|
* @Route(path="/create", name="timesheet_create", methods={"GET", "POST"})
|
|
* @Security("is_granted('create_own_timesheet')")
|
|
*
|
|
* @param Request $request
|
|
* @param ProjectRepository $projectRepository
|
|
* @param ActivityRepository $activityRepository
|
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
|
*/
|
|
public function createAction(Request $request, ProjectRepository $projectRepository, ActivityRepository $activityRepository, TagRepository $tagRepository)
|
|
{
|
|
return $this->create($request, 'timesheet/edit.html.twig', $projectRepository, $activityRepository, $tagRepository);
|
|
}
|
|
}
|