Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)
This commit is contained in:
@@ -19,6 +19,7 @@ use App\Form\Model\MultiUserTimesheet;
|
||||
use App\Form\TimesheetAdminEditForm;
|
||||
use App\Form\TimesheetMultiUserEditForm;
|
||||
use App\Repository\Query\TimesheetQuery;
|
||||
use App\Utils\PageSetup;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
@@ -26,69 +27,51 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
|
||||
/**
|
||||
* @Route(path="/team/timesheet")
|
||||
* @Security("is_granted('view_other_timesheet')")
|
||||
*/
|
||||
class TimesheetTeamController extends TimesheetAbstractController
|
||||
#[Route(path: '/team/timesheet')]
|
||||
#[Security("is_granted('view_other_timesheet')")]
|
||||
final class TimesheetTeamController extends TimesheetAbstractController
|
||||
{
|
||||
/**
|
||||
* @Route(path="/", defaults={"page": 1}, name="admin_timesheet", methods={"GET"})
|
||||
* @Route(path="/page/{page}", requirements={"page": "[1-9]\d*"}, name="admin_timesheet_paginated", methods={"GET"})
|
||||
* @Security("is_granted('view_other_timesheet')")
|
||||
*
|
||||
* @param int $page
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
#[Route(path: '/', defaults: ['page' => 1], name: 'admin_timesheet', methods: ['GET'])]
|
||||
#[Route(path: '/page/{page}', requirements: ['page' => '[1-9]\d*'], name: 'admin_timesheet_paginated', methods: ['GET'])]
|
||||
#[Security("is_granted('view_other_timesheet')")]
|
||||
public function indexAction(int $page, Request $request): Response
|
||||
{
|
||||
$query = $this->createDefaultQuery();
|
||||
$query->setPage($page);
|
||||
|
||||
return $this->index($query, $request, 'admin_timesheet', 'timesheet-team/index.html.twig', TimesheetMetaDisplayEvent::TEAM_TIMESHEET);
|
||||
return $this->index($query, $request, 'admin_timesheet', 'admin_timesheet_paginated', TimesheetMetaDisplayEvent::TEAM_TIMESHEET);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(path="/export/", name="admin_timesheet_export", methods={"GET", "POST"})
|
||||
* @Security("is_granted('export_other_timesheet')")
|
||||
*/
|
||||
#[Route(path: '/export/', name: 'admin_timesheet_export', methods: ['GET', 'POST'])]
|
||||
#[Security("is_granted('export_other_timesheet')")]
|
||||
public function exportAction(Request $request, ServiceExport $serviceExport): Response
|
||||
{
|
||||
return $this->export($request, $serviceExport);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(path="/{id}/edit", name="admin_timesheet_edit", methods={"GET", "POST"})
|
||||
* @Security("is_granted('edit', entry)")
|
||||
*/
|
||||
#[Route(path: '/{id}/edit', name: 'admin_timesheet_edit', methods: ['GET', 'POST'])]
|
||||
#[Security("is_granted('edit', entry)")]
|
||||
public function editAction(Timesheet $entry, Request $request): Response
|
||||
{
|
||||
return $this->edit($entry, $request, 'timesheet-team/edit.html.twig');
|
||||
return $this->edit($entry, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(path="/{id}/duplicate", name="admin_timesheet_duplicate", methods={"GET", "POST"})
|
||||
* @Security("is_granted('duplicate', entry)")
|
||||
*/
|
||||
#[Route(path: '/{id}/duplicate', name: 'admin_timesheet_duplicate', methods: ['GET', 'POST'])]
|
||||
#[Security("is_granted('duplicate', entry)")]
|
||||
public function duplicateAction(Timesheet $entry, Request $request): Response
|
||||
{
|
||||
return $this->duplicate($entry, $request, 'timesheet-team/edit.html.twig');
|
||||
return $this->duplicate($entry, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(path="/create", name="admin_timesheet_create", methods={"GET", "POST"})
|
||||
* @Security("is_granted('create_other_timesheet')")
|
||||
*/
|
||||
#[Route(path: '/create', name: 'admin_timesheet_create', methods: ['GET', 'POST'])]
|
||||
#[Security("is_granted('create_other_timesheet')")]
|
||||
public function createAction(Request $request): Response
|
||||
{
|
||||
return $this->create($request, 'timesheet-team/edit.html.twig');
|
||||
return $this->create($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(path="/create_mu", name="admin_timesheet_create_multiuser", methods={"GET", "POST"})
|
||||
* @Security("is_granted('create_other_timesheet')")
|
||||
*/
|
||||
#[Route(path: '/create_mu', name: 'admin_timesheet_create_multiuser', methods: ['GET', 'POST'])]
|
||||
#[Security("is_granted('create_other_timesheet')")]
|
||||
public function createForMultiUserAction(Request $request): Response
|
||||
{
|
||||
$entry = new MultiUserTimesheet();
|
||||
@@ -134,13 +117,16 @@ class TimesheetTeamController extends TimesheetAbstractController
|
||||
|
||||
return $this->redirectToRoute($this->getTimesheetRoute());
|
||||
} catch (\Exception $ex) {
|
||||
$this->flashUpdateException($ex);
|
||||
// FIXME I guess this will save timesheets for some users, but then fail only for single users
|
||||
// FIXME we should run in a transaction or disallow to create running timesheets
|
||||
$this->handleFormUpdateException($ex, $createForm);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->render('timesheet-team/edit.html.twig', [
|
||||
return $this->render('timesheet/edit.html.twig', [
|
||||
'timesheet' => $entry,
|
||||
'form' => $createForm->createView(),
|
||||
'template' => $this->getTrackingMode()->getEditTemplate(),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -158,26 +144,20 @@ class TimesheetTeamController extends TimesheetAbstractController
|
||||
'allow_end_datetime' => $mode->canEditEnd(),
|
||||
'allow_duration' => $mode->canEditDuration(),
|
||||
'duration_minutes' => $this->configuration->getTimesheetIncrementDuration(),
|
||||
'begin_minutes' => $this->configuration->getTimesheetIncrementBegin(),
|
||||
'end_minutes' => $this->configuration->getTimesheetIncrementEnd(),
|
||||
'timezone' => $this->getDateTimeFactory()->getTimezone()->getName(),
|
||||
'customer' => true,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(path="/multi-update", name="admin_timesheet_multi_update", methods={"POST"})
|
||||
* @Security("is_granted('edit_other_timesheet')")
|
||||
*/
|
||||
#[Route(path: '/multi-update', name: 'admin_timesheet_multi_update', methods: ['POST'])]
|
||||
#[Security("is_granted('edit_other_timesheet')")]
|
||||
public function multiUpdateAction(Request $request): Response
|
||||
{
|
||||
return $this->multiUpdate($request, 'timesheet-team/multi-update.html.twig');
|
||||
return $this->multiUpdate($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route(path="/multi-delete", name="admin_timesheet_multi_delete", methods={"POST"})
|
||||
* @Security("is_granted('delete_other_timesheet')")
|
||||
*/
|
||||
#[Route(path: '/multi-delete', name: 'admin_timesheet_multi_delete', methods: ['POST'])]
|
||||
#[Security("is_granted('delete_other_timesheet')")]
|
||||
public function multiDeleteAction(Request $request): Response
|
||||
{
|
||||
return $this->multiDelete($request);
|
||||
@@ -261,4 +241,42 @@ class TimesheetTeamController extends TimesheetAbstractController
|
||||
{
|
||||
return 'TeamTimes';
|
||||
}
|
||||
|
||||
protected function canSeeRate(): bool
|
||||
{
|
||||
return $this->isGranted('view_rate_other_timesheet');
|
||||
}
|
||||
|
||||
protected function canSeeUsername(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function hasMarkdownSupport(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getTableName(): string
|
||||
{
|
||||
return 'timesheet_admin';
|
||||
}
|
||||
|
||||
protected function getActionName(): string
|
||||
{
|
||||
return 'timesheets_team';
|
||||
}
|
||||
|
||||
protected function getActionNameSingle(): string
|
||||
{
|
||||
return 'timesheet_team';
|
||||
}
|
||||
|
||||
protected function createPageSetup(): PageSetup
|
||||
{
|
||||
$page = new PageSetup('all_times');
|
||||
$page->setHelp('timesheet.html');
|
||||
|
||||
return $page;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user