diff --git a/src/Controller/ActivityController.php b/src/Controller/ActivityController.php
index d0fee335..f311ad63 100644
--- a/src/Controller/ActivityController.php
+++ b/src/Controller/ActivityController.php
@@ -10,6 +10,7 @@
namespace App\Controller;
use App\Entity\Activity;
+use App\Entity\Project;
use App\Form\ActivityEditForm;
use App\Form\Toolbar\ActivityToolbarForm;
use App\Form\Type\ActivityType;
@@ -75,14 +76,21 @@ class ActivityController extends AbstractController
/**
* @Route(path="/create", name="admin_activity_create", methods={"GET", "POST"})
+ * @Route(path="/create/{project}", name="admin_activity_create_with_project", methods={"GET", "POST"})
* @Security("is_granted('create_activity')")
*
* @param Request $request
+ * @param Project|null $project
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
- public function createAction(Request $request)
+ public function createAction(Request $request, ?Project $project = null)
{
- return $this->renderActivityForm(new Activity(), $request);
+ $activity = new Activity();
+ if (null !== $project) {
+ $activity->setProject($project);
+ }
+
+ return $this->renderActivityForm($activity, $request);
}
/**
diff --git a/src/Controller/ProjectController.php b/src/Controller/ProjectController.php
index 556956db..e6c01fa3 100644
--- a/src/Controller/ProjectController.php
+++ b/src/Controller/ProjectController.php
@@ -76,14 +76,22 @@ class ProjectController extends AbstractController
/**
* @Route(path="/create", name="admin_project_create", methods={"GET", "POST"})
+ * @Route(path="/create/{customer}", name="admin_project_create_with_customer", methods={"GET", "POST"})
* @Security("is_granted('create_project')")
*
* @param Request $request
+ * @param Customer|null $customer
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
- public function createAction(Request $request)
+ public function createAction(Request $request, ?Customer $customer = null)
{
- return $this->renderProjectForm(new Project(), $request);
+ $project = new Project();
+
+ if (null !== $customer) {
+ $project->setCustomer($customer);
+ }
+
+ return $this->renderProjectForm($project, $request);
}
/**
diff --git a/src/Controller/TimesheetController.php b/src/Controller/TimesheetController.php
index 20ff6151..3f35cb99 100644
--- a/src/Controller/TimesheetController.php
+++ b/src/Controller/TimesheetController.php
@@ -12,6 +12,8 @@ namespace App\Controller;
use App\Entity\Timesheet;
use App\Form\TimesheetEditForm;
use App\Form\Toolbar\TimesheetToolbarForm;
+use App\Repository\ActivityRepository;
+use App\Repository\ProjectRepository;
use App\Repository\Query\TimesheetQuery;
use Doctrine\ORM\ORMException;
use Pagerfanta\Pagerfanta;
@@ -210,16 +212,18 @@ class TimesheetController extends AbstractController
* @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)
+ public function createAction(Request $request, ProjectRepository $projectRepository, ActivityRepository $activityRepository)
{
$route = 'timesheet';
if ('calendar' === $request->get('origin')) {
$route = 'calendar';
}
- return $this->create($request, $route, 'timesheet/edit.html.twig');
+ return $this->create($request, $route, 'timesheet/edit.html.twig', $projectRepository, $activityRepository);
}
/**
diff --git a/src/Controller/TimesheetControllerTrait.php b/src/Controller/TimesheetControllerTrait.php
index 7e918b85..0a84b056 100644
--- a/src/Controller/TimesheetControllerTrait.php
+++ b/src/Controller/TimesheetControllerTrait.php
@@ -12,6 +12,8 @@ namespace App\Controller;
use App\Configuration\TimesheetConfiguration;
use App\Entity\Timesheet;
use App\Entity\User;
+use App\Repository\ActivityRepository;
+use App\Repository\ProjectRepository;
use App\Repository\TimesheetRepository;
use App\Timesheet\UserDateTimeFactory;
use Doctrine\Common\Persistence\ManagerRegistry;
@@ -116,9 +118,11 @@ trait TimesheetControllerTrait
* @param Request $request
* @param string $redirectRoute
* @param string $renderTemplate
+ * @param ProjectRepository $projectRepository
+ * @param ActivityRepository $activityRepository
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
- protected function create(Request $request, $redirectRoute, $renderTemplate)
+ protected function create(Request $request, $redirectRoute, $renderTemplate, ProjectRepository $projectRepository, ActivityRepository $activityRepository)
{
$entry = new Timesheet();
$entry->setUser($this->getUser());
@@ -158,6 +162,16 @@ trait TimesheetControllerTrait
}
}
+ if ($request->query->get('project')) {
+ $project = $projectRepository->find($request->query->get('project'));
+ $entry->setProject($project);
+ }
+
+ if ($request->query->get('activity')) {
+ $activity = $activityRepository->find($request->query->get('activity'));
+ $entry->setActivity($activity);
+ }
+
$createForm = $this->getCreateForm($entry, $redirectRoute);
$createForm->handleRequest($request);
diff --git a/src/Controller/TimesheetTeamController.php b/src/Controller/TimesheetTeamController.php
index a141f8c1..05d08619 100644
--- a/src/Controller/TimesheetTeamController.php
+++ b/src/Controller/TimesheetTeamController.php
@@ -12,6 +12,8 @@ namespace App\Controller;
use App\Entity\Timesheet;
use App\Form\TimesheetEditForm;
use App\Form\Toolbar\TimesheetToolbarForm;
+use App\Repository\ActivityRepository;
+use App\Repository\ProjectRepository;
use App\Repository\Query\TimesheetQuery;
use Doctrine\ORM\ORMException;
use Pagerfanta\Pagerfanta;
@@ -136,11 +138,13 @@ class TimesheetTeamController extends AbstractController
* @Security("is_granted('create_other_timesheet')")
*
* @param Request $request
+ * @param ProjectRepository $projectRepository
+ * @param ActivityRepository $activityRepository
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
- public function createAction(Request $request)
+ public function createAction(Request $request, ProjectRepository $projectRepository, ActivityRepository $activityRepository)
{
- return $this->create($request, 'admin_timesheet', 'timesheet-team/edit.html.twig');
+ return $this->create($request, 'admin_timesheet', 'timesheet-team/edit.html.twig', $projectRepository, $activityRepository);
}
/**
diff --git a/templates/macros/actions.html.twig b/templates/macros/actions.html.twig
index 06e4e1e0..e8f5ef33 100644
--- a/templates/macros/actions.html.twig
+++ b/templates/macros/actions.html.twig
@@ -23,6 +23,12 @@
{% endif %}
{% set actions = actions|merge({'edit': {'url': path('admin_activity_edit', {'id': activity.id}), 'class': class}}) %}
{% endif %}
+ {% if is_granted('view_other_timesheet') %}
+ {% set actions = actions|merge({'timesheet': path('admin_timesheet', {'customer': activity.project ? activity.project.customer.id : null, 'project': activity.project ? activity.project.id : null, 'activity': activity.id})}) %}
+ {% endif %}
+ {% if is_granted('create_other_timesheet') %}
+ {% set actions = actions|merge({'create-timesheet': path('admin_timesheet_create', {'project': activity.project ? activity.project.id : null, 'activity': activity.id})}) %}
+ {% endif %}
{% if view == 'index' and is_granted('delete', activity) %}
{% set actions = actions|merge({'trash': {'url': path('admin_activity_delete', {'id': activity.id}), 'class': 'modal-ajax-form'}}) %}
{% endif %}
@@ -109,6 +115,12 @@
{% if is_granted('view_activity') %}
{% set actions = actions|merge({'activity': path('admin_activity', {'customer': project.customer.id, 'project': project.id})}) %}
{% endif %}
+ {% if is_granted('view_other_timesheet') %}
+ {% set actions = actions|merge({'timesheet': path('admin_timesheet', {'customer': project.customer.id, 'project': project.id})}) %}
+ {% endif %}
+ {% if is_granted('create_activity') and project.visible and project.customer.visible %}
+ {% set actions = actions|merge({'create-activity': path('admin_activity_create_with_project', {'project': project.id})}) %}
+ {% endif %}
{% if view == 'index' and is_granted('delete', project) %}
{% set actions = actions|merge({'trash': {'url': path('admin_project_delete', {'id': project.id}), 'class': 'modal-ajax-form'}}) %}
{% endif %}
@@ -153,6 +165,15 @@
{% if is_granted('view_project') %}
{% set actions = actions|merge({'project': path('admin_project', {'customer': customer.id})}) %}
{% endif %}
+ {% if is_granted('view_activity') %}
+ {% set actions = actions|merge({'activity': path('admin_activity', {'customer': customer.id})}) %}
+ {% endif %}
+ {% if is_granted('view_other_timesheet') %}
+ {% set actions = actions|merge({'timesheet': path('admin_timesheet', {'customer': customer.id})}) %}
+ {% endif %}
+ {% if is_granted('create_project') and customer.visible %}
+ {% set actions = actions|merge({'create-project': path('admin_project_create_with_customer', {'customer': customer.id})}) %}
+ {% endif %}
{% if view == 'index' and is_granted('delete', customer) %}
{% set actions = actions|merge({'trash': {'url': path('admin_customer_delete', {'id': customer.id}), 'class': 'modal-ajax-form'}}) %}
{% endif %}
@@ -193,14 +214,12 @@
{% set actions = {} %}
{% if timesheet.id is not empty %}
- {% if timesheet.end %}
- {% if is_granted('start', timesheet) %}
- {% set actions = actions|merge({'repeat': path('timesheet_start', {'id' : timesheet.id})}) %}
- {% endif %}
- {% else %}
- {% if is_granted('stop', timesheet) %}
- {% set actions = actions|merge({'stop': path('timesheet_stop', {'id' : timesheet.id})}) %}
- {% endif %}
+ {% if not timesheet.end and is_granted('stop', timesheet) %}
+ {% set actions = actions|merge({'stop': path('timesheet_stop', {'id' : timesheet.id})}) %}
+ {% endif %}
+
+ {% if timesheet.end and is_granted('start', timesheet) %}
+ {% set actions = actions|merge({'repeat': path('timesheet_start', {'id' : timesheet.id})}) %}
{% endif %}
{% if is_granted('edit', timesheet) %}
@@ -250,6 +269,14 @@
{% set actions = {} %}
{% if timesheet.id is not empty %}
+ {% if not timesheet.end and is_granted('stop', timesheet) %}
+ {% set actions = actions|merge({'stop': path('admin_timesheet_stop', {'id' : timesheet.id})}) %}
+ {% endif %}
+
+ {% if timesheet.end and is_granted('start', timesheet) %}
+ {% set actions = actions|merge({'repeat': path('timesheet_start', {'id' : timesheet.id})}) %}
+ {% endif %}
+
{% if is_granted('edit', timesheet) %}
{% set class = '' %}
{% if view != 'edit' %}
@@ -258,10 +285,6 @@
{% set actions = actions|merge({'edit': {'url': path('admin_timesheet_edit', {'id': timesheet.id}), 'class': class}}) %}
{% endif %}
- {% if not timesheet.end and is_granted('stop', timesheet) %}
- {% set actions = actions|merge({'stop': path('admin_timesheet_stop', {'id' : timesheet.id})}) %}
- {% endif %}
-
{% if view == 'index' and is_granted('delete', timesheet) %}
{% set actions = actions|merge({'trash': {'url': path('admin_timesheet_delete', {'id' : timesheet.id}), 'class': 'modal-ajax-form'}}) %}
{% endif %}
diff --git a/translations/actions.de.xliff b/translations/actions.de.xliff
index 5cf23c88..06992253 100644
--- a/translations/actions.de.xliff
+++ b/translations/actions.de.xliff
@@ -46,6 +46,18 @@
home
Homepage
+
+ create-project
+ Projekt erstellen
+
+
+ create-activity
+ Tätigkeit erstellen
+
+
+ create-timesheet
+ Zeit erfassen
+