timesheet export (#317)
* remove autocomplete for begin and end * fix minute display in timesheet-edit form * toolbar form label in separate row * added export action
This commit is contained in:
@@ -60,6 +60,12 @@ class TimesheetController extends AbstractController
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/* @var $entries Pagerfanta */
|
||||
@@ -118,7 +124,7 @@ class TimesheetController extends AbstractController
|
||||
/**
|
||||
* The route to delete an existing entry.
|
||||
*
|
||||
* @Route(path="/{id}/delete", name="admin_timesheet_delete", methods={"GET", "POST"})
|
||||
* @Route(path="/{id}/delete", defaults={"page": 1}, name="admin_timesheet_delete", methods={"GET", "POST"})
|
||||
* @Security("is_granted('delete', entry)")
|
||||
*
|
||||
* @param Timesheet $entry
|
||||
|
||||
@@ -42,6 +42,10 @@ class TimesheetController extends AbstractController
|
||||
* @Route(path="/", defaults={"page": 1}, name="timesheet", methods={"GET"})
|
||||
* @Route(path="/page/{page}", requirements={"page": "[1-9]\d*"}, name="timesheet_paginated", methods={"GET"})
|
||||
* @Cache(smaxage="10")
|
||||
*
|
||||
* @param int $page
|
||||
* @param Request $request
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function indexAction($page, Request $request)
|
||||
{
|
||||
@@ -53,6 +57,12 @@ class TimesheetController extends AbstractController
|
||||
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());
|
||||
@@ -69,7 +79,41 @@ class TimesheetController extends AbstractController
|
||||
}
|
||||
|
||||
/**
|
||||
* The "main button and flyout" for displaying (and stopping) active entries.
|
||||
* @Route(path="/export", name="timesheet_export", methods={"GET"})
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function exportAction(Request $request)
|
||||
{
|
||||
$query = new TimesheetQuery();
|
||||
|
||||
$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());
|
||||
|
||||
/* @var $entries Pagerfanta */
|
||||
$entries = $this->getRepository()->findByQuery($query);
|
||||
|
||||
return $this->render('timesheet/export.html.twig', [
|
||||
'entries' => $entries,
|
||||
'query' => $query,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The "main button and fly-out" for displaying (and stopping) active entries.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
@@ -155,7 +199,7 @@ class TimesheetController extends AbstractController
|
||||
/**
|
||||
* The route to delete an existing entry.
|
||||
*
|
||||
* @Route(path="/{id}/delete", name="timesheet_delete", methods={"GET", "POST"})
|
||||
* @Route(path="/{id}/delete", defaults={"page": 1}, name="timesheet_delete", methods={"GET", "POST"})
|
||||
* @Security("is_granted('delete', entry)")
|
||||
*
|
||||
* @param Timesheet $entry
|
||||
|
||||
@@ -92,8 +92,6 @@ trait TimesheetControllerTrait
|
||||
$record->setEnd($end);
|
||||
}
|
||||
|
||||
// TODO validate that end is not before begin
|
||||
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->persist($entry);
|
||||
$entityManager->flush();
|
||||
@@ -170,8 +168,6 @@ trait TimesheetControllerTrait
|
||||
}
|
||||
}
|
||||
|
||||
// TODO validate that end is not before begin
|
||||
|
||||
$entityManager = $this->getDoctrine()->getManager();
|
||||
$entityManager->persist($entry);
|
||||
|
||||
|
||||
@@ -85,6 +85,14 @@ class Activity
|
||||
*/
|
||||
private $hourlyRate = null;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Timesheet[]
|
||||
*/
|
||||
@@ -113,8 +121,6 @@ class Activity
|
||||
}
|
||||
|
||||
/**
|
||||
* Set name
|
||||
*
|
||||
* @param string $name
|
||||
* @return Activity
|
||||
*/
|
||||
@@ -126,8 +132,6 @@ class Activity
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
@@ -136,8 +140,6 @@ class Activity
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment
|
||||
*
|
||||
* @param string $comment
|
||||
* @return Activity
|
||||
*/
|
||||
@@ -149,8 +151,6 @@ class Activity
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getComment()
|
||||
@@ -159,10 +159,7 @@ class Activity
|
||||
}
|
||||
|
||||
/**
|
||||
* Set visible
|
||||
*
|
||||
* @param bool $visible
|
||||
*
|
||||
* @return Activity
|
||||
*/
|
||||
public function setVisible($visible)
|
||||
@@ -173,8 +170,6 @@ class Activity
|
||||
}
|
||||
|
||||
/**
|
||||
* Get visible
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getVisible()
|
||||
@@ -182,16 +177,6 @@ class Activity
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get activity id
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
|
||||
@@ -102,8 +102,6 @@ class Project
|
||||
private $hourlyRate = null;
|
||||
|
||||
/**
|
||||
* Get projectid
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
@@ -144,8 +142,6 @@ class Project
|
||||
}
|
||||
|
||||
/**
|
||||
* Get name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
@@ -154,8 +150,6 @@ class Project
|
||||
}
|
||||
|
||||
/**
|
||||
* Set comment
|
||||
*
|
||||
* @param string $comment
|
||||
* @return Project
|
||||
*/
|
||||
@@ -167,8 +161,6 @@ class Project
|
||||
}
|
||||
|
||||
/**
|
||||
* Get comment
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getComment()
|
||||
@@ -177,8 +169,6 @@ class Project
|
||||
}
|
||||
|
||||
/**
|
||||
* Set visible
|
||||
*
|
||||
* @param bool $visible
|
||||
* @return Project
|
||||
*/
|
||||
@@ -190,8 +180,6 @@ class Project
|
||||
}
|
||||
|
||||
/**
|
||||
* Get visible
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function getVisible()
|
||||
@@ -200,8 +188,6 @@ class Project
|
||||
}
|
||||
|
||||
/**
|
||||
* Set budget
|
||||
*
|
||||
* @param float $budget
|
||||
* @return Project
|
||||
*/
|
||||
@@ -213,8 +199,6 @@ class Project
|
||||
}
|
||||
|
||||
/**
|
||||
* Get budget
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getBudget()
|
||||
@@ -242,7 +226,7 @@ class Project
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getOrderNumber(): ?string
|
||||
{
|
||||
|
||||
@@ -44,9 +44,9 @@ class TimesheetEditForm extends AbstractType
|
||||
'label' => 'label.begin',
|
||||
'widget' => 'single_text',
|
||||
'html5' => false,
|
||||
'format' => 'yyyy-MM-dd H:m',
|
||||
'format' => 'yyyy-MM-dd HH:mm',
|
||||
'with_seconds' => false,
|
||||
'attr' => ['data-datetimepicker' => 'on'],
|
||||
'attr' => ['autocomplete' => 'off', 'data-datetimepicker' => 'on'],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -58,9 +58,9 @@ class TimesheetEditForm extends AbstractType
|
||||
'widget' => 'single_text',
|
||||
'required' => false,
|
||||
'html5' => false,
|
||||
'format' => 'yyyy-MM-dd H:m',
|
||||
'format' => 'yyyy-MM-dd HH:mm',
|
||||
'with_seconds' => false,
|
||||
'attr' => ['data-datetimepicker' => 'on'],
|
||||
'attr' => ['autocomplete' => 'off', 'data-datetimepicker' => 'on'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -110,7 +110,8 @@ abstract class AbstractToolbarForm extends AbstractType
|
||||
'widget' => 'single_text',
|
||||
'html5' => false,
|
||||
'required' => false,
|
||||
'attr' => ['data-datepicker' => 'on'],
|
||||
'format' => 'yyyy-MM-dd',
|
||||
'attr' => ['autocomplete' => 'off', 'data-datepicker' => 'on'],
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -124,7 +125,8 @@ abstract class AbstractToolbarForm extends AbstractType
|
||||
'widget' => 'single_text',
|
||||
'html5' => false,
|
||||
'required' => false,
|
||||
'attr' => ['data-datepicker' => 'on'],
|
||||
'format' => 'yyyy-MM-dd',
|
||||
'attr' => ['autocomplete' => 'off', 'data-datepicker' => 'on'],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,8 @@ class TimesheetAdminToolbarForm extends TimesheetToolbarForm
|
||||
$this->addTimesheetStateChoice($builder);
|
||||
$this->addPageSizeChoice($builder);
|
||||
$this->addUserChoice($builder);
|
||||
$this->addStartDateChoice($builder);
|
||||
$this->addEndDateChoice($builder);
|
||||
$this->addCustomerChoice($builder);
|
||||
$this->addProjectChoice($builder);
|
||||
$this->addActivityChoice($builder);
|
||||
|
||||
@@ -26,6 +26,8 @@ class TimesheetToolbarForm extends AbstractToolbarForm
|
||||
{
|
||||
$this->addTimesheetStateChoice($builder);
|
||||
$this->addPageSizeChoice($builder);
|
||||
$this->addStartDateChoice($builder);
|
||||
$this->addEndDateChoice($builder);
|
||||
$this->addCustomerChoice($builder);
|
||||
$this->addProjectChoice($builder);
|
||||
$this->addActivityChoice($builder);
|
||||
|
||||
@@ -62,6 +62,8 @@ class Extensions extends \Twig_Extension
|
||||
'create' => 'far fa-plus-square',
|
||||
'dashboard' => 'fas fa-tachometer-alt',
|
||||
'delete' => 'far fa-trash-alt',
|
||||
'download' => 'fas fa-download',
|
||||
'duration' => 'far fa-hourglass',
|
||||
'edit' => 'far fa-edit',
|
||||
'filter' => 'fas fa-filter',
|
||||
'help' => 'far fa-question-circle',
|
||||
@@ -69,6 +71,7 @@ class Extensions extends \Twig_Extension
|
||||
'list' => 'fas fa-list',
|
||||
'logout' => 'fas fa-sign-out-alt',
|
||||
'manual' => 'fas fa-book',
|
||||
'money' => 'far fa-money-bill-alt',
|
||||
'print' => 'fas fa-print',
|
||||
'project' => 'fas fa-project-diagram',
|
||||
'repeat' => 'fas fa-redo-alt',
|
||||
@@ -80,8 +83,6 @@ class Extensions extends \Twig_Extension
|
||||
'trash' => 'far fa-trash-alt',
|
||||
'user' => 'fas fa-user',
|
||||
'visibility' => 'far fa-eye',
|
||||
'money' => 'far fa-money-bill-alt',
|
||||
'duration' => 'far fa-hourglass',
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user