billable timesheets, inactive projects report, bookmark export search (#2503)

This commit is contained in:
Kevin Papst
2021-04-18 21:51:27 +02:00
committed by GitHub
parent 8664d94ea6
commit 0330f45c6a
97 changed files with 1516 additions and 664 deletions

View File

@@ -196,7 +196,9 @@ abstract class AbstractController extends BaseAbstractController implements Serv
// apply bookmark ONLY if search form was not submitted manually
if ($bookmark !== null && !$request->query->has('performSearch')) {
$data->setBookmark($bookmark);
$submitData = array_merge($bookmark->getContent(), $submitData);
if (!$request->query->has('setDefaultQuery')) {
$submitData = array_merge($bookmark->getContent(), $submitData);
}
}
// clean up parameters from unknown search values

View File

@@ -311,7 +311,7 @@ final class ActivityController extends AbstractController
$deleteForm = $this->createFormBuilder(null, [
'attr' => [
'data-form-event' => 'kimai.activityUpdate kimai.activityDelete',
'data-form-event' => 'kimai.activityDelete',
'data-msg-success' => 'action.delete.success',
'data-msg-error' => 'action.delete.error',
]

View File

@@ -376,7 +376,7 @@ final class CustomerController extends AbstractController
$deleteForm = $this->createFormBuilder(null, [
'attr' => [
'data-form-event' => 'kimai.customerUpdate kimai.customerDelete',
'data-form-event' => 'kimai.customerDelete',
'data-msg-success' => 'action.delete.success',
'data-msg-error' => 'action.delete.error',
]

View File

@@ -15,7 +15,6 @@ use App\Form\Toolbar\ExportToolbarForm;
use App\Repository\Query\ExportQuery;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\SubmitButton;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
@@ -50,26 +49,40 @@ class ExportController extends AbstractController
$entries = [];
$form = $this->getToolbarForm($query, 'GET');
$form->setData($query);
$form->submit($request->query->all(), false);
if ($this->handleSearch($form, $request)) {
return $this->redirectToRoute('export');
}
if ($form->isValid()) {
/** @var SubmitButton $previewButton */
$previewButton = $form->get('preview');
if ($previewButton->isClicked()) {
$showPreview = true;
$query->setPageSize($maxItemsPreview);
$entries = $this->getEntries($query);
$byCustomer = [];
if ($form->isValid() && ($query->hasBookmark() || $request->query->has('performSearch'))) {
$showPreview = true;
$entries = $this->getEntries($query);
foreach ($entries as $entry) {
$cid = $entry->getProject()->getCustomer()->getId();
if (!isset($byCustomer[$cid])) {
$byCustomer[$cid] = [
'customer' => $entry->getProject()->getCustomer(),
'rate' => 0,
'internalRate' => 0,
'duration' => 0,
];
}
$byCustomer[$cid]['rate'] += $entry->getRate();
$byCustomer[$cid]['internalRate'] += $entry->getInternalRate();
$byCustomer[$cid]['duration'] += $entry->getDuration();
}
}
return $this->render('export/index.html.twig', [
'by_customer' => $byCustomer,
'query' => $query,
'entries' => $entries,
'form' => $form->createView(),
'renderer' => $this->export->getRenderer(),
'preview_max' => $maxItemsPreview,
'preview_limit' => $maxItemsPreview,
'preview_show' => $showPreview,
'decimal' => $this->getUser()->isExportDecimal(),
]);
}

View File

@@ -420,7 +420,7 @@ final class ProjectController extends AbstractController
$deleteForm = $this->createFormBuilder(null, [
'attr' => [
'data-form-event' => 'kimai.projectUpdate kimai.projectDelete',
'data-form-event' => 'kimai.projectDelete',
'data-msg-success' => 'action.delete.success',
'data-msg-error' => 'action.delete.error',
]

View File

@@ -0,0 +1,57 @@
<?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\Reporting;
use App\Controller\AbstractController;
use App\Reporting\ProjectInactive\ProjectInactiveForm;
use App\Reporting\ProjectInactive\ProjectInactiveQuery;
use App\Reporting\ProjectStatisticService;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
final class InactiveProjectController extends AbstractController
{
/**
* @Route(path="/reporting/project_inactive", name="report_project_inactive", methods={"GET","POST"})
* @Security("is_granted('view_reporting') and is_granted('budget_project')")
*/
public function __invoke(Request $request, ProjectStatisticService $service)
{
$dateFactory = $this->getDateTimeFactory();
$user = $this->getUser();
$query = new ProjectInactiveQuery($dateFactory->createDateTime('-1 year'), $user);
$form = $this->createForm(ProjectInactiveForm::class, $query, [
'timezone' => $user->getTimezone()
]);
$form->submit($request->query->all(), false);
$projects = $service->findInactiveProjects($query);
$entries = $service->getProjectView($user, $projects, $query->getLastChange());
$byCustomer = [];
foreach ($entries as $entry) {
$customer = $entry->getProject()->getCustomer();
if (!isset($byCustomer[$customer->getId()])) {
$byCustomer[$customer->getId()] = ['customer' => $customer, 'projects' => []];
}
$byCustomer[$customer->getId()]['projects'][] = $entry;
}
return $this->render('reporting/project_view.html.twig', [
'entries' => $byCustomer,
'form' => $form->createView(),
'title' => 'report_inactive_project',
'tableName' => 'inactive_project_reporting',
'now' => $this->getDateTimeFactory()->createDateTime(),
]);
}
}

View File

@@ -10,9 +10,9 @@
namespace App\Controller\Reporting;
use App\Controller\AbstractController;
use App\Reporting\ProjectStatisticService;
use App\Reporting\ProjectView\ProjectViewForm;
use App\Reporting\ProjectView\ProjectViewQuery;
use App\Reporting\ProjectView\ProjectViewService;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
@@ -23,17 +23,17 @@ final class ProjectViewController extends AbstractController
* @Route(path="/reporting/project_view", name="report_project_view", methods={"GET","POST"})
* @Security("is_granted('view_reporting') and is_granted('budget_project')")
*/
public function __invoke(Request $request, ProjectViewService $service)
public function __invoke(Request $request, ProjectStatisticService $service)
{
$query = new ProjectViewQuery($this->getDateTimeFactory()->createDateTime(), $this->getUser());
$form = $this->createForm(ProjectViewForm::class, $query, [
'action' => $this->generateUrl('report_project_view')
]);
$dateFactory = $this->getDateTimeFactory();
$user = $this->getUser();
$query = new ProjectViewQuery($dateFactory->createDateTime(), $user);
$form = $this->createForm(ProjectViewForm::class, $query);
$form->submit($request->query->all(), false);
$entries = $service->getProjectView($query);
$projects = $service->findProjectsForView($query);
$entries = $service->getProjectView($user, $projects, $query->getToday());
$byCustomer = [];
foreach ($entries as $entry) {
@@ -47,6 +47,9 @@ final class ProjectViewController extends AbstractController
return $this->render('reporting/project_view.html.twig', [
'entries' => $byCustomer,
'form' => $form->createView(),
'title' => 'report_project_view',
'tableName' => 'project_view_reporting',
'now' => $this->getDateTimeFactory()->createDateTime(),
]);
}
}