fix timesheet collection fetch via API with end datetime set (#2552)
This commit is contained in:
@@ -138,7 +138,7 @@ class TimesheetController extends BaseApiController
|
|||||||
*/
|
*/
|
||||||
public function cgetAction(ParamFetcherInterface $paramFetcher): Response
|
public function cgetAction(ParamFetcherInterface $paramFetcher): Response
|
||||||
{
|
{
|
||||||
$query = new TimesheetQuery();
|
$query = new TimesheetQuery(false);
|
||||||
$query->setUser($this->getUser());
|
$query->setUser($this->getUser());
|
||||||
|
|
||||||
if ($this->isGranted('view_other_timesheet') && null !== ($user = $paramFetcher->get('user'))) {
|
if ($this->isGranted('view_other_timesheet') && null !== ($user = $paramFetcher->get('user'))) {
|
||||||
|
|||||||
@@ -13,9 +13,15 @@ use DateTime;
|
|||||||
|
|
||||||
final class DateRange
|
final class DateRange
|
||||||
{
|
{
|
||||||
|
private $resetTimes;
|
||||||
private $begin;
|
private $begin;
|
||||||
private $end;
|
private $end;
|
||||||
|
|
||||||
|
public function __construct(bool $resetTimes = true)
|
||||||
|
{
|
||||||
|
$this->resetTimes = $resetTimes;
|
||||||
|
}
|
||||||
|
|
||||||
public function getBegin(): ?DateTime
|
public function getBegin(): ?DateTime
|
||||||
{
|
{
|
||||||
return $this->begin;
|
return $this->begin;
|
||||||
@@ -24,7 +30,9 @@ final class DateRange
|
|||||||
public function setBegin(DateTime $begin): DateRange
|
public function setBegin(DateTime $begin): DateRange
|
||||||
{
|
{
|
||||||
$this->begin = $begin;
|
$this->begin = $begin;
|
||||||
$this->begin->setTime(0, 0, 0);
|
if ($this->resetTimes) {
|
||||||
|
$this->begin->setTime(0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -37,7 +45,9 @@ final class DateRange
|
|||||||
public function setEnd(DateTime $end): DateRange
|
public function setEnd(DateTime $end): DateRange
|
||||||
{
|
{
|
||||||
$this->end = $end;
|
$this->end = $end;
|
||||||
$this->end->setTime(23, 59, 59);
|
if ($this->resetTimes) {
|
||||||
|
$this->end->setTime(23, 59, 59);
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,13 +59,13 @@ class TimesheetQuery extends ActivityQuery implements BillableInterface
|
|||||||
*/
|
*/
|
||||||
private $users = [];
|
private $users = [];
|
||||||
|
|
||||||
public function __construct()
|
public function __construct(bool $resetTimes = true)
|
||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
$this->setDefaults([
|
$this->setDefaults([
|
||||||
'order' => self::ORDER_DESC,
|
'order' => self::ORDER_DESC,
|
||||||
'orderBy' => 'begin',
|
'orderBy' => 'begin',
|
||||||
'dateRange' => new DateRange()
|
'dateRange' => new DateRange($resetTimes)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user