timesheet controller refactoring (#796)
This commit is contained in:
@@ -31,6 +31,7 @@ import KimaiEvent from "./plugins/KimaiEvent";
|
|||||||
import KimaiAPILink from "./plugins/KimaiAPILink";
|
import KimaiAPILink from "./plugins/KimaiAPILink";
|
||||||
import KimaiAlert from "./plugins/KimaiAlert";
|
import KimaiAlert from "./plugins/KimaiAlert";
|
||||||
import KimaiAutocomplete from "./plugins/KimaiAutocomplete";
|
import KimaiAutocomplete from "./plugins/KimaiAutocomplete";
|
||||||
|
import KimaiToolbarAction from "./plugins/KimaiToolbarAction";
|
||||||
|
|
||||||
export default class KimaiLoader {
|
export default class KimaiLoader {
|
||||||
|
|
||||||
@@ -61,6 +62,7 @@ export default class KimaiLoader {
|
|||||||
kimai.registerPlugin(new KimaiActiveRecords('li.messages-menu', 'li.messages-menu-empty'));
|
kimai.registerPlugin(new KimaiActiveRecords('li.messages-menu', 'li.messages-menu-empty'));
|
||||||
kimai.registerPlugin(new KimaiAPILink('api-link'));
|
kimai.registerPlugin(new KimaiAPILink('api-link'));
|
||||||
kimai.registerPlugin(new KimaiAutocomplete('.js-autocomplete'));
|
kimai.registerPlugin(new KimaiAutocomplete('.js-autocomplete'));
|
||||||
|
kimai.registerPlugin(new KimaiToolbarAction('toolbar-action'));
|
||||||
//kimai.registerPlugin(new KimaiPauseRecord('li.messages-menu ul.menu li'));
|
//kimai.registerPlugin(new KimaiPauseRecord('li.messages-menu ul.menu li'));
|
||||||
|
|
||||||
// notify all listeners that Kimai plugins can now be registered
|
// notify all listeners that Kimai plugins can now be registered
|
||||||
|
|||||||
56
assets/js/plugins/KimaiToolbarAction.js
Normal file
56
assets/js/plugins/KimaiToolbarAction.js
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import KimaiPlugin from '../KimaiPlugin';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Needs to be initialized with a class name.
|
||||||
|
*
|
||||||
|
* A link like <a href=# class=remoteLink> can be activated with:
|
||||||
|
* new KimaiToolbarAction('remoteLink')
|
||||||
|
*
|
||||||
|
* @param selector
|
||||||
|
*/
|
||||||
|
export default class KimaiToolbarAction extends KimaiPlugin {
|
||||||
|
|
||||||
|
constructor(selector) {
|
||||||
|
super();
|
||||||
|
this.selector = selector;
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
|
const self = this;
|
||||||
|
document.addEventListener('click', function(event) {
|
||||||
|
let target = event.target;
|
||||||
|
while (!target.matches('body')) {
|
||||||
|
if (target.classList.contains(self.selector)) {
|
||||||
|
const form = document.querySelector('div.toolbar form.navbar-form');
|
||||||
|
if (form === null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const prevAction = form.action;
|
||||||
|
const prevMethod = form.method;
|
||||||
|
form.target = '_blank';
|
||||||
|
form.action = target.href;
|
||||||
|
if (target.dataset.method !== undefined) {
|
||||||
|
form.method = target.dataset.method;
|
||||||
|
}
|
||||||
|
form.submit();
|
||||||
|
form.target = '';
|
||||||
|
form.action = prevAction;
|
||||||
|
form.method = prevMethod;
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
}
|
||||||
|
|
||||||
|
target = target.parentNode;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"build/app.js": "./app.js?748657cabe85b735a003",
|
"build/app.js": "./app.js?4d1c16b6cec885d40370",
|
||||||
"build/app.css": "./app.css?e4b4080f26821060103657b889a6b1cd",
|
"build/app.css": "./app.css?e4b4080f26821060103657b889a6b1cd",
|
||||||
"build/fonts/fa-solid-900.woff2": "./fonts/fa-solid-900.woff2?e8a92a29",
|
"build/fonts/fa-solid-900.woff2": "./fonts/fa-solid-900.woff2?e8a92a29",
|
||||||
"build/images/fa-solid-900.svg": "./images/fa-solid-900.svg?666a82cb",
|
"build/images/fa-solid-900.svg": "./images/fa-solid-900.svg?666a82cb",
|
||||||
|
|||||||
@@ -10,21 +10,22 @@
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Configuration\TimesheetConfiguration;
|
use App\Configuration\TimesheetConfiguration;
|
||||||
|
use App\Entity\Tag;
|
||||||
use App\Entity\Timesheet;
|
use App\Entity\Timesheet;
|
||||||
use App\Entity\User;
|
use App\Form\TimesheetEditForm;
|
||||||
|
use App\Form\Toolbar\TimesheetToolbarForm;
|
||||||
use App\Repository\ActivityRepository;
|
use App\Repository\ActivityRepository;
|
||||||
use App\Repository\ProjectRepository;
|
use App\Repository\ProjectRepository;
|
||||||
|
use App\Repository\Query\TimesheetQuery;
|
||||||
use App\Repository\TimesheetRepository;
|
use App\Repository\TimesheetRepository;
|
||||||
use App\Timesheet\UserDateTimeFactory;
|
use App\Timesheet\UserDateTimeFactory;
|
||||||
use Doctrine\Common\Persistence\ManagerRegistry;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
use Pagerfanta\Pagerfanta;
|
||||||
|
use Symfony\Component\Form\FormInterface;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
/**
|
abstract class TimesheetAbstractController extends AbstractController
|
||||||
* Helper functions for Timesheet controller
|
|
||||||
*/
|
|
||||||
trait TimesheetControllerTrait
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var UserDateTimeFactory
|
* @var UserDateTimeFactory
|
||||||
@@ -61,14 +62,56 @@ trait TimesheetControllerTrait
|
|||||||
return $this->getDoctrine()->getRepository(Timesheet::class);
|
return $this->getDoctrine()->getRepository(Timesheet::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function index($page, Request $request, string $renderTemplate)
|
||||||
|
{
|
||||||
|
$query = new TimesheetQuery();
|
||||||
|
$query->setPage($page);
|
||||||
|
|
||||||
|
$form = $this->getToolbarForm($query);
|
||||||
|
$form->handleRequest($request);
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
/** @var TimesheetQuery $query */
|
||||||
|
$query = $form->getData();
|
||||||
|
if (null !== $query->getBegin()) {
|
||||||
|
$query->getBegin()->setTime(0, 0, 0);
|
||||||
|
}
|
||||||
|
if (null !== $query->getEnd()) {
|
||||||
|
$query->getEnd()->setTime(23, 59, 59);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->includeUserInForms()) {
|
||||||
|
$query->setUser($this->getUser());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($query->hasTags()) {
|
||||||
|
$query->setTags(
|
||||||
|
new ArrayCollection(
|
||||||
|
$this->getDoctrine()->getRepository(Tag::class)->findIdsByTagNameList(implode(',', $query->getTags()->toArray()))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* @var $entries Pagerfanta */
|
||||||
|
$entries = $this->getRepository()->findByQuery($query);
|
||||||
|
|
||||||
|
return $this->render($renderTemplate, [
|
||||||
|
'entries' => $entries,
|
||||||
|
'page' => $query->getPage(),
|
||||||
|
'query' => $query,
|
||||||
|
'showFilter' => $form->isSubmitted(),
|
||||||
|
'toolbarForm' => $form->createView(),
|
||||||
|
'showSummary' => $this->includeSummary(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Timesheet $entry
|
* @param Timesheet $entry
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param string $redirectRoute
|
|
||||||
* @param string $renderTemplate
|
* @param string $renderTemplate
|
||||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
protected function edit(Timesheet $entry, Request $request, $redirectRoute, $renderTemplate)
|
protected function edit(Timesheet $entry, Request $request, string $renderTemplate)
|
||||||
{
|
{
|
||||||
$editForm = $this->getEditForm($entry, $request->get('page'));
|
$editForm = $this->getEditForm($entry, $request->get('page'));
|
||||||
$editForm->handleRequest($request);
|
$editForm->handleRequest($request);
|
||||||
@@ -80,7 +123,7 @@ trait TimesheetControllerTrait
|
|||||||
|
|
||||||
$this->flashSuccess('action.update.success');
|
$this->flashSuccess('action.update.success');
|
||||||
|
|
||||||
return $this->redirectToRoute($redirectRoute, ['page' => $request->get('page', 1)]);
|
return $this->redirectToRoute($this->getTimesheetRoute(), ['page' => $request->get('page', 1)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render($renderTemplate, [
|
return $this->render($renderTemplate, [
|
||||||
@@ -91,13 +134,12 @@ trait TimesheetControllerTrait
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @param string $redirectRoute
|
|
||||||
* @param string $renderTemplate
|
* @param string $renderTemplate
|
||||||
* @param ProjectRepository $projectRepository
|
* @param ProjectRepository $projectRepository
|
||||||
* @param ActivityRepository $activityRepository
|
* @param ActivityRepository $activityRepository
|
||||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
*/
|
*/
|
||||||
protected function create(Request $request, $redirectRoute, $renderTemplate, ProjectRepository $projectRepository, ActivityRepository $activityRepository)
|
protected function create(Request $request, string $renderTemplate, ProjectRepository $projectRepository, ActivityRepository $activityRepository)
|
||||||
{
|
{
|
||||||
$entry = new Timesheet();
|
$entry = new Timesheet();
|
||||||
$entry->setUser($this->getUser());
|
$entry->setUser($this->getUser());
|
||||||
@@ -173,7 +215,7 @@ trait TimesheetControllerTrait
|
|||||||
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
|
$this->flashError('action.update.error', ['%reason%' => $ex->getMessage()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->redirectToRoute($redirectRoute);
|
return $this->redirectToRoute($this->getTimesheetRoute());
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->render($renderTemplate, [
|
return $this->render($renderTemplate, [
|
||||||
@@ -182,57 +224,119 @@ trait TimesheetControllerTrait
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @param string $renderTemplate
|
||||||
|
* @return Response
|
||||||
|
*/
|
||||||
|
protected function export(Request $request, string $renderTemplate)
|
||||||
|
{
|
||||||
|
$query = new TimesheetQuery();
|
||||||
|
$query->setResultType(TimesheetQuery::RESULT_TYPE_OBJECTS);
|
||||||
|
|
||||||
|
$form = $this->getToolbarForm($query);
|
||||||
|
$form->handleRequest($request);
|
||||||
|
if ($form->isSubmitted() && $form->isValid()) {
|
||||||
|
/** @var TimesheetQuery $query */
|
||||||
|
$query = $form->getData();
|
||||||
|
}
|
||||||
|
|
||||||
|
// by default the current month is exported, but it can be overwritten
|
||||||
|
// this should not be removed, otherwise we would export EVERY available record in the admin section
|
||||||
|
// as the default toolbar query does neither limit the user nor the date-range!
|
||||||
|
if (null === $query->getBegin()) {
|
||||||
|
$query->setBegin($this->dateTime->createDateTime('first day of this month'));
|
||||||
|
}
|
||||||
|
$query->getBegin()->setTime(0, 0, 0);
|
||||||
|
|
||||||
|
if (null === $query->getEnd()) {
|
||||||
|
$query->setEnd($this->dateTime->createDateTime('last day of this month'));
|
||||||
|
}
|
||||||
|
$query->getEnd()->setTime(23, 59, 59);
|
||||||
|
|
||||||
|
if (!$this->includeUserInForms()) {
|
||||||
|
$query->setUser($this->getUser());
|
||||||
|
}
|
||||||
|
|
||||||
|
/* @var $entries Pagerfanta */
|
||||||
|
$entries = $this->getRepository()->findByQuery($query);
|
||||||
|
|
||||||
|
return $this->render($renderTemplate, [
|
||||||
|
'entries' => $entries,
|
||||||
|
'query' => $query,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Timesheet $entry
|
* @param Timesheet $entry
|
||||||
* @return \Symfony\Component\Form\FormInterface
|
* @return \Symfony\Component\Form\FormInterface
|
||||||
*/
|
*/
|
||||||
abstract protected function getCreateForm(Timesheet $entry);
|
protected function getCreateForm(Timesheet $entry)
|
||||||
|
{
|
||||||
|
return $this->createForm(TimesheetEditForm::class, $entry, [
|
||||||
|
'action' => $this->generateUrl($this->getCreateRoute()),
|
||||||
|
'include_rate' => $this->isGranted('edit_rate', $entry),
|
||||||
|
'include_user' => $this->includeUserInForms(),
|
||||||
|
'customer' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Timesheet $entry
|
* @param Timesheet $entry
|
||||||
* @param int $page
|
* @param int $page
|
||||||
* @return \Symfony\Component\Form\FormInterface
|
* @return FormInterface
|
||||||
*/
|
*/
|
||||||
abstract protected function getEditForm(Timesheet $entry, $page);
|
protected function getEditForm(Timesheet $entry, $page)
|
||||||
|
{
|
||||||
|
return $this->createForm(TimesheetEditForm::class, $entry, [
|
||||||
|
'action' => $this->generateUrl($this->getEditRoute(), [
|
||||||
|
'id' => $entry->getId(),
|
||||||
|
'page' => $page,
|
||||||
|
]),
|
||||||
|
'include_rate' => $this->isGranted('edit_rate', $entry),
|
||||||
|
'include_exported' => $this->isGranted('edit_export', $entry),
|
||||||
|
'include_user' => $this->includeUserInForms(),
|
||||||
|
'customer' => true,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a "successful" flash message to the stack.
|
* @param TimesheetQuery $query
|
||||||
*
|
* @return FormInterface
|
||||||
* @param string $translationKey
|
|
||||||
* @param array $parameter
|
|
||||||
*/
|
*/
|
||||||
abstract protected function flashSuccess($translationKey, $parameter = []);
|
protected function getToolbarForm(TimesheetQuery $query)
|
||||||
|
{
|
||||||
|
return $this->createForm(TimesheetToolbarForm::class, $query, [
|
||||||
|
'action' => $this->generateUrl($this->getTimesheetRoute(), [
|
||||||
|
'page' => $query->getPage(),
|
||||||
|
]),
|
||||||
|
'method' => 'GET',
|
||||||
|
'include_user' => $this->includeUserInForms(),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
protected function includeSummary(): bool
|
||||||
* Adds a "error" flash message to the stack.
|
{
|
||||||
*
|
return (bool) $this->getUser()->getPreferenceValue('timesheet.daily_stats', false);
|
||||||
* @param $translationKey
|
}
|
||||||
* @param array $parameter
|
|
||||||
*/
|
|
||||||
abstract protected function flashError($translationKey, $parameter = []);
|
|
||||||
|
|
||||||
/**
|
protected function includeUserInForms(): bool
|
||||||
* Shortcut to return the Doctrine Registry service.
|
{
|
||||||
*
|
return false;
|
||||||
* @throws \LogicException If DoctrineBundle is not available
|
}
|
||||||
*/
|
|
||||||
abstract protected function getDoctrine(): ManagerRegistry;
|
|
||||||
|
|
||||||
/**
|
protected function getTimesheetRoute(): string
|
||||||
* Returns a RedirectResponse to the given route with the given parameters.
|
{
|
||||||
*/
|
return 'timesheet';
|
||||||
abstract protected function redirectToRoute(string $route, array $parameters = [], int $status = 302): RedirectResponse;
|
}
|
||||||
|
|
||||||
/**
|
protected function getEditRoute(): string
|
||||||
* Renders a view.
|
{
|
||||||
*/
|
return 'timesheet_edit';
|
||||||
abstract protected function render(string $view, array $parameters = [], Response $response = null): Response;
|
}
|
||||||
|
|
||||||
/**
|
protected function getCreateRoute(): string
|
||||||
* Get a user from the Security Token Storage.
|
{
|
||||||
*
|
return 'timesheet_create';
|
||||||
* @return User
|
}
|
||||||
* @throws \LogicException If SecurityBundle is not available
|
|
||||||
*/
|
|
||||||
abstract protected function getUser();
|
|
||||||
}
|
}
|
||||||
@@ -9,29 +9,19 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\Tag;
|
|
||||||
use App\Entity\Timesheet;
|
use App\Entity\Timesheet;
|
||||||
use App\Form\TimesheetEditForm;
|
|
||||||
use App\Form\Toolbar\TimesheetToolbarForm;
|
|
||||||
use App\Repository\ActivityRepository;
|
use App\Repository\ActivityRepository;
|
||||||
use App\Repository\ProjectRepository;
|
use App\Repository\ProjectRepository;
|
||||||
use App\Repository\Query\TimesheetQuery;
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Pagerfanta\Pagerfanta;
|
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller used to manage timesheets.
|
|
||||||
*
|
|
||||||
* @Route(path="/timesheet")
|
* @Route(path="/timesheet")
|
||||||
* @Security("is_granted('view_own_timesheet')")
|
* @Security("is_granted('view_own_timesheet')")
|
||||||
*/
|
*/
|
||||||
class TimesheetController extends AbstractController
|
class TimesheetController extends TimesheetAbstractController
|
||||||
{
|
{
|
||||||
use TimesheetControllerTrait;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route(path="/", defaults={"page": 1}, name="timesheet", methods={"GET"})
|
* @Route(path="/", defaults={"page": 1}, name="timesheet", methods={"GET"})
|
||||||
* @Route(path="/page/{page}", requirements={"page": "[1-9]\d*"}, name="timesheet_paginated", methods={"GET"})
|
* @Route(path="/page/{page}", requirements={"page": "[1-9]\d*"}, name="timesheet_paginated", methods={"GET"})
|
||||||
@@ -43,43 +33,7 @@ class TimesheetController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
public function indexAction($page, Request $request)
|
public function indexAction($page, Request $request)
|
||||||
{
|
{
|
||||||
$query = new TimesheetQuery();
|
return $this->index($page, $request, 'timesheet/index.html.twig');
|
||||||
$query->setPage($page);
|
|
||||||
|
|
||||||
$form = $this->getToolbarForm($query);
|
|
||||||
$form->handleRequest($request);
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
|
||||||
/** @var TimesheetQuery $query */
|
|
||||||
$query = $form->getData();
|
|
||||||
if (null !== $query->getBegin()) {
|
|
||||||
$query->getBegin()->setTime(0, 0, 0);
|
|
||||||
}
|
|
||||||
if (null !== $query->getEnd()) {
|
|
||||||
$query->getEnd()->setTime(23, 59, 59);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$query->setUser($this->getUser());
|
|
||||||
|
|
||||||
if ($query->hasTags()) {
|
|
||||||
$query->setTags(
|
|
||||||
new ArrayCollection(
|
|
||||||
$this->getDoctrine()->getRepository(Tag::class)->findIdsByTagNameList(implode(',', $query->getTags()->toArray()))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* @var $entries Pagerfanta */
|
|
||||||
$entries = $this->getRepository()->findByQuery($query);
|
|
||||||
|
|
||||||
return $this->render('timesheet/index.html.twig', [
|
|
||||||
'entries' => $entries,
|
|
||||||
'page' => $query->getPage(),
|
|
||||||
'query' => $query,
|
|
||||||
'showFilter' => $form->isSubmitted(),
|
|
||||||
'toolbarForm' => $form->createView(),
|
|
||||||
'showSummary' => $this->getUser()->getPreferenceValue('timesheet.daily_stats', false),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,37 +45,34 @@ class TimesheetController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
public function exportAction(Request $request)
|
public function exportAction(Request $request)
|
||||||
{
|
{
|
||||||
$query = new TimesheetQuery();
|
return $this->export($request, 'timesheet/export.html.twig');
|
||||||
$query->setResultType(TimesheetQuery::RESULT_TYPE_OBJECTS);
|
|
||||||
|
|
||||||
$form = $this->getToolbarForm($query);
|
|
||||||
$form->handleRequest($request);
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
|
||||||
/** @var TimesheetQuery $query */
|
|
||||||
$query = $form->getData();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// by default the current month is exported, but it can be overwritten
|
/**
|
||||||
if (null === $query->getBegin()) {
|
* @Route(path="/{id}/edit", name="timesheet_edit", methods={"GET", "POST"})
|
||||||
$query->setBegin($this->dateTime->createDateTime('first day of this month'));
|
* @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');
|
||||||
}
|
}
|
||||||
$query->getBegin()->setTime(0, 0, 0);
|
|
||||||
|
|
||||||
if (null === $query->getEnd()) {
|
/**
|
||||||
$query->setEnd($this->dateTime->createDateTime('last day of this month'));
|
* @Route(path="/create", name="timesheet_create", methods={"GET", "POST"})
|
||||||
}
|
* @Security("is_granted('create_own_timesheet')")
|
||||||
$query->getEnd()->setTime(23, 59, 59);
|
*
|
||||||
|
* @param Request $request
|
||||||
// user timesheet always export for the session user
|
* @param ProjectRepository $projectRepository
|
||||||
$query->setUser($this->getUser());
|
* @param ActivityRepository $activityRepository
|
||||||
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
/* @var $entries Pagerfanta */
|
*/
|
||||||
$entries = $this->getRepository()->findByQuery($query);
|
public function createAction(Request $request, ProjectRepository $projectRepository, ActivityRepository $activityRepository)
|
||||||
|
{
|
||||||
return $this->render('timesheet/export.html.twig', [
|
return $this->create($request, 'timesheet/edit.html.twig', $projectRepository, $activityRepository);
|
||||||
'entries' => $entries,
|
|
||||||
'query' => $query,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -142,76 +93,4 @@ class TimesheetController extends AbstractController
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @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', 'timesheet/edit.html.twig');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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)
|
|
||||||
{
|
|
||||||
return $this->create($request, 'timesheet', 'timesheet/edit.html.twig', $projectRepository, $activityRepository);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Timesheet $entry
|
|
||||||
* @return \Symfony\Component\Form\FormInterface
|
|
||||||
*/
|
|
||||||
protected function getCreateForm(Timesheet $entry)
|
|
||||||
{
|
|
||||||
return $this->createForm(TimesheetEditForm::class, $entry, [
|
|
||||||
'action' => $this->generateUrl('timesheet_create', []),
|
|
||||||
'include_rate' => $this->isGranted('edit_rate', $entry),
|
|
||||||
'customer' => true,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param Timesheet $entry
|
|
||||||
* @param int $page
|
|
||||||
* @return \Symfony\Component\Form\FormInterface
|
|
||||||
*/
|
|
||||||
protected function getEditForm(Timesheet $entry, $page)
|
|
||||||
{
|
|
||||||
return $this->createForm(TimesheetEditForm::class, $entry, [
|
|
||||||
'action' => $this->generateUrl('timesheet_edit', [
|
|
||||||
'id' => $entry->getId(),
|
|
||||||
'page' => $page,
|
|
||||||
]),
|
|
||||||
'include_rate' => $this->isGranted('edit_rate', $entry),
|
|
||||||
'include_exported' => $this->isGranted('edit_export', $entry),
|
|
||||||
'customer' => true,
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param TimesheetQuery $query
|
|
||||||
* @return \Symfony\Component\Form\FormInterface
|
|
||||||
*/
|
|
||||||
protected function getToolbarForm(TimesheetQuery $query)
|
|
||||||
{
|
|
||||||
return $this->createForm(TimesheetToolbarForm::class, $query, [
|
|
||||||
'action' => $this->generateUrl('timesheet', [
|
|
||||||
'page' => $query->getPage(),
|
|
||||||
]),
|
|
||||||
'method' => 'GET',
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,29 +9,19 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Entity\Tag;
|
|
||||||
use App\Entity\Timesheet;
|
use App\Entity\Timesheet;
|
||||||
use App\Form\TimesheetEditForm;
|
|
||||||
use App\Form\Toolbar\TimesheetToolbarForm;
|
|
||||||
use App\Repository\ActivityRepository;
|
use App\Repository\ActivityRepository;
|
||||||
use App\Repository\ProjectRepository;
|
use App\Repository\ProjectRepository;
|
||||||
use App\Repository\Query\TimesheetQuery;
|
|
||||||
use Doctrine\Common\Collections\ArrayCollection;
|
|
||||||
use Pagerfanta\Pagerfanta;
|
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller used for manage timesheet entries in the admin part of the site.
|
|
||||||
*
|
|
||||||
* @Route(path="/team/timesheet")
|
* @Route(path="/team/timesheet")
|
||||||
* @Security("is_granted('view_other_timesheet')")
|
* @Security("is_granted('view_other_timesheet')")
|
||||||
*/
|
*/
|
||||||
class TimesheetTeamController extends AbstractController
|
class TimesheetTeamController extends TimesheetAbstractController
|
||||||
{
|
{
|
||||||
use TimesheetControllerTrait;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route(path="/", defaults={"page": 1}, name="admin_timesheet", methods={"GET"})
|
* @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"})
|
* @Route(path="/page/{page}", requirements={"page": "[1-9]\d*"}, name="admin_timesheet_paginated", methods={"GET"})
|
||||||
@@ -43,40 +33,7 @@ class TimesheetTeamController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
public function indexAction($page, Request $request)
|
public function indexAction($page, Request $request)
|
||||||
{
|
{
|
||||||
$query = new TimesheetQuery();
|
return $this->index($page, $request, 'timesheet-team/index.html.twig');
|
||||||
$query->setPage($page);
|
|
||||||
|
|
||||||
$form = $this->getToolbarForm($query);
|
|
||||||
$form->handleRequest($request);
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
|
||||||
/** @var TimesheetQuery $query */
|
|
||||||
$query = $form->getData();
|
|
||||||
if (null !== $query->getBegin()) {
|
|
||||||
$query->getBegin()->setTime(0, 0, 0);
|
|
||||||
}
|
|
||||||
if (null !== $query->getEnd()) {
|
|
||||||
$query->getEnd()->setTime(23, 59, 59);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($query->hasTags()) {
|
|
||||||
$query->setTags(
|
|
||||||
new ArrayCollection(
|
|
||||||
$this->getDoctrine()->getRepository(Tag::class)->findIdsByTagNameList(implode(',', $query->getTags()->toArray()))
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* @var $entries Pagerfanta */
|
|
||||||
$entries = $this->getRepository()->findByQuery($query);
|
|
||||||
|
|
||||||
return $this->render('timesheet-team/index.html.twig', [
|
|
||||||
'entries' => $entries,
|
|
||||||
'page' => $query->getPage(),
|
|
||||||
'query' => $query,
|
|
||||||
'showFilter' => $form->isSubmitted(),
|
|
||||||
'toolbarForm' => $form->createView(),
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,34 +44,7 @@ class TimesheetTeamController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
public function exportAction(Request $request)
|
public function exportAction(Request $request)
|
||||||
{
|
{
|
||||||
$query = new TimesheetQuery();
|
return $this->export($request, 'timesheet-team/export.html.twig');
|
||||||
$query->setResultType(TimesheetQuery::RESULT_TYPE_OBJECTS);
|
|
||||||
|
|
||||||
$form = $this->getToolbarForm($query);
|
|
||||||
$form->handleRequest($request);
|
|
||||||
if ($form->isSubmitted() && $form->isValid()) {
|
|
||||||
/** @var TimesheetQuery $query */
|
|
||||||
$query = $form->getData();
|
|
||||||
}
|
|
||||||
|
|
||||||
// by default the current month is exported, but it can be overwritten
|
|
||||||
if (null === $query->getBegin()) {
|
|
||||||
$query->setBegin($this->dateTime->createDateTime('first day of this month'));
|
|
||||||
}
|
|
||||||
$query->getBegin()->setTime(0, 0, 0);
|
|
||||||
|
|
||||||
if (null === $query->getEnd()) {
|
|
||||||
$query->setEnd($this->dateTime->createDateTime('last day of this month'));
|
|
||||||
}
|
|
||||||
$query->getEnd()->setTime(23, 59, 59);
|
|
||||||
|
|
||||||
/* @var $entries Pagerfanta */
|
|
||||||
$entries = $this->getRepository()->findByQuery($query);
|
|
||||||
|
|
||||||
return $this->render('timesheet-team/export.html.twig', [
|
|
||||||
'entries' => $entries,
|
|
||||||
'query' => $query,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,7 +57,7 @@ class TimesheetTeamController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
public function editAction(Timesheet $entry, Request $request)
|
public function editAction(Timesheet $entry, Request $request)
|
||||||
{
|
{
|
||||||
return $this->edit($entry, $request, 'admin_timesheet', 'timesheet-team/edit.html.twig');
|
return $this->edit($entry, $request, 'timesheet-team/edit.html.twig');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -141,54 +71,26 @@ class TimesheetTeamController extends AbstractController
|
|||||||
*/
|
*/
|
||||||
public function createAction(Request $request, ProjectRepository $projectRepository, ActivityRepository $activityRepository)
|
public function createAction(Request $request, ProjectRepository $projectRepository, ActivityRepository $activityRepository)
|
||||||
{
|
{
|
||||||
return $this->create($request, 'admin_timesheet', 'timesheet-team/edit.html.twig', $projectRepository, $activityRepository);
|
return $this->create($request, 'timesheet-team/edit.html.twig', $projectRepository, $activityRepository);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function includeUserInForms(): bool
|
||||||
* @param Timesheet $entry
|
|
||||||
* @return \Symfony\Component\Form\FormInterface
|
|
||||||
*/
|
|
||||||
protected function getCreateForm(Timesheet $entry)
|
|
||||||
{
|
{
|
||||||
return $this->createForm(TimesheetEditForm::class, $entry, [
|
return true;
|
||||||
'action' => $this->generateUrl('admin_timesheet_create'),
|
|
||||||
'include_rate' => $this->isGranted('edit_rate', $entry),
|
|
||||||
'include_user' => true,
|
|
||||||
'customer' => true,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function getTimesheetRoute(): string
|
||||||
* @param Timesheet $entry
|
|
||||||
* @param int $page
|
|
||||||
* @return \Symfony\Component\Form\FormInterface
|
|
||||||
*/
|
|
||||||
protected function getEditForm(Timesheet $entry, $page)
|
|
||||||
{
|
{
|
||||||
return $this->createForm(TimesheetEditForm::class, $entry, [
|
return 'admin_timesheet';
|
||||||
'action' => $this->generateUrl('admin_timesheet_edit', [
|
|
||||||
'id' => $entry->getId(),
|
|
||||||
'page' => $page,
|
|
||||||
]),
|
|
||||||
'include_rate' => $this->isGranted('edit_rate', $entry),
|
|
||||||
'include_exported' => $this->isGranted('edit_export', $entry),
|
|
||||||
'include_user' => true,
|
|
||||||
'customer' => true,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function getEditRoute(): string
|
||||||
* @param TimesheetQuery $query
|
|
||||||
* @return \Symfony\Component\Form\FormInterface
|
|
||||||
*/
|
|
||||||
protected function getToolbarForm(TimesheetQuery $query)
|
|
||||||
{
|
{
|
||||||
return $this->createForm(TimesheetToolbarForm::class, $query, [
|
return 'admin_timesheet_edit';
|
||||||
'action' => $this->generateUrl('admin_timesheet', [
|
}
|
||||||
'page' => $query->getPage(),
|
|
||||||
]),
|
protected function getCreateRoute(): string
|
||||||
'method' => 'GET',
|
{
|
||||||
'include_user' => true,
|
return 'admin_timesheet_create';
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -361,7 +361,7 @@ class TimesheetEditForm extends AbstractType
|
|||||||
'docu_chapter' => 'timesheet.html',
|
'docu_chapter' => 'timesheet.html',
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'date_format' => null,
|
'date_format' => null,
|
||||||
'customer' => false,
|
'customer' => false, // for API usage
|
||||||
'attr' => [
|
'attr' => [
|
||||||
'data-form-event' => 'kimai.timesheetUpdate',
|
'data-form-event' => 'kimai.timesheetUpdate',
|
||||||
'data-msg-success' => 'action.update.success',
|
'data-msg-success' => 'action.update.success',
|
||||||
|
|||||||
@@ -79,28 +79,12 @@
|
|||||||
{% if is_granted('create_invoice') %}
|
{% if is_granted('create_invoice') %}
|
||||||
<div class="row no-print">
|
<div class="row no-print">
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
<button type="button" id="print-invoice-button" class="btn btn-success pull-right">
|
<a href="{{ path('invoice_print') }}" class="btn btn-success pull-right toolbar-action">
|
||||||
<i class="{{ 'print'|icon }}"></i> {{ 'button.print'|trans }}
|
<i class="{{ 'print'|icon }}"></i> {{ 'button.print'|trans }}
|
||||||
</button>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block javascripts %}
|
|
||||||
{{ parent() }}
|
|
||||||
{% if is_granted('create_invoice') %}
|
|
||||||
<script type="text/javascript">
|
|
||||||
document.addEventListener('kimai.initialized', function() {
|
|
||||||
$("body").on('click', '#print-invoice-button', function() {
|
|
||||||
var prevAction = $( "#invoice-print-form" ).attr('action');
|
|
||||||
$( "#invoice-print-form" ).attr('target', '_blank').attr('action', '{{ path('invoice_print') }}');
|
|
||||||
$( "#invoice-print-form" ).submit();
|
|
||||||
$( "#invoice-print-form" ).removeAttr('target').attr('action', prevAction);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|||||||
@@ -208,7 +208,7 @@
|
|||||||
|
|
||||||
{% set actions = {'filter': '#collapseTimesheet'} %}
|
{% set actions = {'filter': '#collapseTimesheet'} %}
|
||||||
{% if is_granted('export_own_timesheet') %}
|
{% if is_granted('export_own_timesheet') %}
|
||||||
{% set actions = actions|merge({'download': {'onclick': 'return exportTimesheet()'}}) %}
|
{% set actions = actions|merge({'download': {'url': path('timesheet_export'), 'class': 'toolbar-action'}}) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% set actions = actions|merge({'visibility': '#modal_timesheet'}) %}
|
{% set actions = actions|merge({'visibility': '#modal_timesheet'}) %}
|
||||||
{% if is_granted('create_own_timesheet') %}
|
{% if is_granted('create_own_timesheet') %}
|
||||||
@@ -264,7 +264,7 @@
|
|||||||
|
|
||||||
{% set actions = {'filter': '#collapseTimesheetAdmin'} %}
|
{% set actions = {'filter': '#collapseTimesheetAdmin'} %}
|
||||||
{% if is_granted('export_own_timesheet') %}
|
{% if is_granted('export_own_timesheet') %}
|
||||||
{% set actions = actions|merge({'download': 'onclick:return exportTimesheet()'}) %}
|
{% set actions = actions|merge({'download': {'url': path('admin_timesheet_export'), 'class': 'toolbar-action'}}) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% set actions = actions|merge({'visibility': '#modal_timesheet_admin'}) %}
|
{% set actions = actions|merge({'visibility': '#modal_timesheet_admin'}) %}
|
||||||
{% if is_granted('create_other_timesheet') %}
|
{% if is_granted('create_other_timesheet') %}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
{% for entry in entries %}
|
{% for entry in entries %}
|
||||||
{% set timeWorked = timeWorked + entry.duration %}
|
{% set timeWorked = timeWorked + entry.duration %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ entry.begin|date_short }}</td>
|
<td class="text-nowrap">{{ entry.begin|date_short }}</td>
|
||||||
{% if query.user is empty %}
|
{% if query.user is empty %}
|
||||||
<td>{{ widgets.username(entry.user) }}</td>
|
<td>{{ widgets.username(entry.user) }}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
{{ 'label.customer'|trans }}: {{ entry.project.customer.name }}
|
{{ 'label.customer'|trans }}: {{ entry.project.customer.name }}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ entry.duration|duration }}</td>
|
<td class="text-nowrap">{{ entry.duration|duration }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -4,13 +4,17 @@
|
|||||||
{% import "macros/toolbar.html.twig" as toolbar %}
|
{% import "macros/toolbar.html.twig" as toolbar %}
|
||||||
{% import "macros/actions.html.twig" as actions %}
|
{% import "macros/actions.html.twig" as actions %}
|
||||||
|
|
||||||
|
{% set tableName = 'timesheet_admin' %}
|
||||||
{% set duration_only = is_duration_only() %}
|
{% set duration_only = is_duration_only() %}
|
||||||
{% set columns = {
|
{% set columns = {
|
||||||
'date': 'alwaysVisible',
|
'date': 'alwaysVisible',
|
||||||
} %}
|
} %}
|
||||||
|
|
||||||
{% if not duration_only %}
|
{% if not duration_only %}
|
||||||
{% set columns = columns|merge({'starttime': 'hidden-xs', 'endtime': 'hidden-xs'}) %}
|
{% set columns = columns|merge({
|
||||||
|
'starttime': 'hidden-xs',
|
||||||
|
'endtime': 'hidden-xs'
|
||||||
|
}) %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% set columns = columns|merge({
|
{% set columns = columns|merge({
|
||||||
@@ -25,8 +29,6 @@
|
|||||||
'actions': 'actions alwaysVisible',
|
'actions': 'actions alwaysVisible',
|
||||||
}) %}
|
}) %}
|
||||||
|
|
||||||
{% set tableName = 'timesheet_admin' %}
|
|
||||||
|
|
||||||
{% block page_title %}{{ 'admin_timesheet.title'|trans }}{% endblock %}
|
{% block page_title %}{{ 'admin_timesheet.title'|trans }}{% endblock %}
|
||||||
{% block page_subtitle %}{{ 'admin_timesheet.subtitle'|trans }}{% endblock %}
|
{% block page_subtitle %}{{ 'admin_timesheet.subtitle'|trans }}{% endblock %}
|
||||||
{% block page_actions %}{{ actions.timesheets_team('index') }}{% endblock %}
|
{% block page_actions %}{{ actions.timesheets_team('index') }}{% endblock %}
|
||||||
@@ -49,21 +51,23 @@
|
|||||||
|
|
||||||
{% if not duration_only %}
|
{% if not duration_only %}
|
||||||
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'starttime') }}">{{ entry.begin|time }}</td>
|
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'starttime') }}">{{ entry.begin|time }}</td>
|
||||||
|
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'endtime') }}">
|
||||||
|
{% if entry.end %}
|
||||||
|
{{ entry.end|time }}
|
||||||
|
{% else %}
|
||||||
|
‐
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if entry.end %}
|
{% if entry.end %}
|
||||||
{% if not duration_only %}
|
|
||||||
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'endtime') }}">{{ entry.end|time }}</td>
|
|
||||||
{% endif %}
|
|
||||||
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'duration') }}">{{ entry.duration|duration }}</td>
|
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'duration') }}">{{ entry.duration|duration }}</td>
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if not duration_only %}
|
|
||||||
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'endtime') }}">‐</td>
|
|
||||||
{% endif %}
|
|
||||||
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'duration') }}">
|
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'duration') }}">
|
||||||
<i data-since="{{ entry.begin.format(constant('DATE_ISO8601')) }}" data-format="{{ get_format_duration() }}">{{ entry|duration }}</i>
|
<i data-since="{{ entry.begin.format(constant('DATE_ISO8601')) }}" data-format="{{ get_format_duration() }}">{{ entry|duration }}</i>
|
||||||
</td>
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'rate') }}">
|
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'rate') }}">
|
||||||
{% if not entry.end or not is_granted('view_rate', entry) %}
|
{% if not entry.end or not is_granted('view_rate', entry) %}
|
||||||
‐
|
‐
|
||||||
@@ -86,7 +90,7 @@
|
|||||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'description') }}">{{ entry.description|nl2br }}</td>
|
<td class="{{ tables.data_table_column_class(tableName, columns, 'description') }}">{{ entry.description|nl2br }}</td>
|
||||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'tags') }}">{{ widgets.tag_list(entry.tags) }}</td>
|
<td class="{{ tables.data_table_column_class(tableName, columns, 'tags') }}">{{ widgets.tag_list(entry.tags) }}</td>
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
{{ actions.timesheet_team(entry, 'index') }}
|
{{- actions.timesheet_team(entry, 'index') -}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -95,17 +99,3 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block javascripts %}
|
|
||||||
{{ parent() }}
|
|
||||||
<script type="text/javascript">
|
|
||||||
function exportTimesheet() {
|
|
||||||
var form = $("div.toolbar form.navbar-form");
|
|
||||||
var prevAction = form.attr('action');
|
|
||||||
form.attr('target', '_blank').attr('action', '{{ path('admin_timesheet_export') }}');
|
|
||||||
form.submit();
|
|
||||||
form.removeAttr('target').attr('action', prevAction);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
{% for entry in entries %}
|
{% for entry in entries %}
|
||||||
{% set timeWorked = timeWorked + entry.duration %}
|
{% set timeWorked = timeWorked + entry.duration %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ entry.begin|date_short }}</td>
|
<td class="text-nowrap">{{ entry.begin|date_short }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if entry.description is not empty %}
|
{% if entry.description is not empty %}
|
||||||
<div>
|
<div>
|
||||||
@@ -50,7 +50,7 @@
|
|||||||
{{ 'label.customer'|trans }}: {{ entry.project.customer.name }}
|
{{ 'label.customer'|trans }}: {{ entry.project.customer.name }}
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ entry.duration|duration }}</td>
|
<td class="text-nowrap">{{ entry.duration|duration }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
{% set columns = {
|
{% set columns = {
|
||||||
'date': 'alwaysVisible',
|
'date': 'alwaysVisible',
|
||||||
} %}
|
} %}
|
||||||
|
|
||||||
{% if not duration_only %}
|
{% if not duration_only %}
|
||||||
{% set columns = columns|merge({
|
{% set columns = columns|merge({
|
||||||
'starttime': '',
|
'starttime': '',
|
||||||
@@ -40,6 +41,7 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
|
|
||||||
{% if entries.count == 0 %}
|
{% if entries.count == 0 %}
|
||||||
{{ widgets.callout('warning', 'error.no_entries_found') }}
|
{{ widgets.callout('warning', 'error.no_entries_found') }}
|
||||||
{% else %}
|
{% else %}
|
||||||
@@ -64,26 +66,31 @@
|
|||||||
|
|
||||||
{% if not duration_only %}
|
{% if not duration_only %}
|
||||||
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'starttime') }}">{{ entry.begin|time }}</td>
|
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'starttime') }}">{{ entry.begin|time }}</td>
|
||||||
|
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'endtime') }}">
|
||||||
|
{% if entry.end %}
|
||||||
|
{{ entry.end|time }}
|
||||||
|
{% else %}
|
||||||
|
‐
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if entry.end %}
|
{% if entry.end %}
|
||||||
{% if not duration_only %}
|
|
||||||
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'endtime') }}">{{ entry.end|time }}</td>
|
|
||||||
{% endif %}
|
|
||||||
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'duration') }}">{{ entry.duration|duration }}</td>
|
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'duration') }}">{{ entry.duration|duration }}</td>
|
||||||
{% if canSeeRate %}
|
|
||||||
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'rate') }}">{{ entry.rate|money(entry.project.customer.currency) }}</td>
|
|
||||||
{% endif %}
|
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if not duration_only %}
|
|
||||||
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'endtime') }}">‐</td>
|
|
||||||
{% endif %}
|
|
||||||
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'duration') }}">
|
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'duration') }}">
|
||||||
<i data-since="{{ entry.begin.format(constant('DATE_ISO8601')) }}" data-format="{{ get_format_duration() }}">{{ entry|duration }}</i>
|
<i data-since="{{ entry.begin.format(constant('DATE_ISO8601')) }}" data-format="{{ get_format_duration() }}">{{ entry|duration }}</i>
|
||||||
</td>
|
</td>
|
||||||
{% if canSeeRate %}
|
|
||||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'rate') }}">‐</td>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if canSeeRate %}
|
||||||
|
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'rate') }}">
|
||||||
|
{% if not entry.end %}
|
||||||
|
‐
|
||||||
|
{% else %}
|
||||||
|
{{ entry.rate|money(entry.project.customer.currency) }}
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<td class="{{ tables.data_table_column_class(tableName, columns, 'customer') }}">{{ widgets.label_customer(entry.project.customer) }}</td>
|
<td class="{{ tables.data_table_column_class(tableName, columns, 'customer') }}">{{ widgets.label_customer(entry.project.customer) }}</td>
|
||||||
@@ -113,20 +120,6 @@
|
|||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block javascripts %}
|
|
||||||
{{ parent() }}
|
|
||||||
<script type="text/javascript">
|
|
||||||
function exportTimesheet() {
|
|
||||||
var form = $("div.toolbar form.navbar-form");
|
|
||||||
var prevAction = form.attr('action');
|
|
||||||
form.attr('target', '_blank').attr('action', '{{ path('timesheet_export') }}');
|
|
||||||
form.submit();
|
|
||||||
form.removeAttr('target').attr('action', prevAction);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% macro summary(day, duration, dayRates, columns, canSeeRate, duration_only, tableName) %}
|
{% macro summary(day, duration, dayRates, columns, canSeeRate, duration_only, tableName) %}
|
||||||
{% import "macros/datatables.html.twig" as tables %}
|
{% import "macros/datatables.html.twig" as tables %}
|
||||||
<tr class="summary info">
|
<tr class="summary info">
|
||||||
|
|||||||
@@ -10,9 +10,7 @@
|
|||||||
namespace App\Tests\EventSubscriber;
|
namespace App\Tests\EventSubscriber;
|
||||||
|
|
||||||
use App\Entity\User;
|
use App\Entity\User;
|
||||||
use App\Event\DashboardEvent;
|
|
||||||
use App\Event\ThemeEvent;
|
use App\Event\ThemeEvent;
|
||||||
use App\Model\DashboardSection;
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user