monthly budget, monthly report, unified report calculation (#2684)
This commit is contained in:
64
src/Event/ActivityBudgetStatisticEvent.php
Normal file
64
src/Event/ActivityBudgetStatisticEvent.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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\Event;
|
||||
|
||||
use App\Model\ActivityBudgetStatisticModel;
|
||||
|
||||
final class ActivityBudgetStatisticEvent
|
||||
{
|
||||
private $models;
|
||||
private $begin;
|
||||
private $end;
|
||||
|
||||
/**
|
||||
* @param ActivityBudgetStatisticModel[] $models
|
||||
* @param \DateTime|null $begin
|
||||
* @param \DateTime|null $end
|
||||
*/
|
||||
public function __construct(array $models, ?\DateTime $begin = null, ?\DateTime $end = null)
|
||||
{
|
||||
$this->models = $models;
|
||||
$this->begin = $begin;
|
||||
$this->end = $end;
|
||||
}
|
||||
|
||||
public function getModel(int $activityId): ?ActivityBudgetStatisticModel
|
||||
{
|
||||
if (isset($this->models[$activityId])) {
|
||||
return $this->models[$activityId];
|
||||
}
|
||||
|
||||
foreach ($this->models as $model) {
|
||||
if ($model->getActivity()->getId() === $activityId) {
|
||||
return $model;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ActivityBudgetStatisticModel[]
|
||||
*/
|
||||
public function getModels(): array
|
||||
{
|
||||
return $this->models;
|
||||
}
|
||||
|
||||
public function getBegin(): ?\DateTime
|
||||
{
|
||||
return $this->begin;
|
||||
}
|
||||
|
||||
public function getEnd(): ?\DateTime
|
||||
{
|
||||
return $this->end;
|
||||
}
|
||||
}
|
||||
@@ -15,15 +15,29 @@ use App\Model\ActivityStatistic;
|
||||
final class ActivityStatisticEvent extends AbstractActivityEvent
|
||||
{
|
||||
private $statistic;
|
||||
private $begin;
|
||||
private $end;
|
||||
|
||||
public function __construct(Activity $activity, ActivityStatistic $statistic)
|
||||
public function __construct(Activity $activity, ActivityStatistic $statistic, \DateTime $begin = null, \DateTime $end = null)
|
||||
{
|
||||
parent::__construct($activity);
|
||||
$this->statistic = $statistic;
|
||||
$this->begin = $begin;
|
||||
$this->end = $end;
|
||||
}
|
||||
|
||||
public function getStatistic(): ActivityStatistic
|
||||
{
|
||||
return $this->statistic;
|
||||
}
|
||||
|
||||
public function getBegin(): ?\DateTime
|
||||
{
|
||||
return $this->begin;
|
||||
}
|
||||
|
||||
public function getEnd(): ?\DateTime
|
||||
{
|
||||
return $this->end;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,15 +15,29 @@ use App\Model\CustomerStatistic;
|
||||
final class CustomerStatisticEvent extends AbstractCustomerEvent
|
||||
{
|
||||
private $statistic;
|
||||
private $begin;
|
||||
private $end;
|
||||
|
||||
public function __construct(Customer $customer, CustomerStatistic $statistic)
|
||||
public function __construct(Customer $customer, CustomerStatistic $statistic, \DateTime $begin = null, \DateTime $end = null)
|
||||
{
|
||||
parent::__construct($customer);
|
||||
$this->statistic = $statistic;
|
||||
$this->begin = $begin;
|
||||
$this->end = $end;
|
||||
}
|
||||
|
||||
public function getStatistic(): CustomerStatistic
|
||||
{
|
||||
return $this->statistic;
|
||||
}
|
||||
|
||||
public function getBegin(): ?\DateTime
|
||||
{
|
||||
return $this->begin;
|
||||
}
|
||||
|
||||
public function getEnd(): ?\DateTime
|
||||
{
|
||||
return $this->end;
|
||||
}
|
||||
}
|
||||
|
||||
64
src/Event/ProjectBudgetStatisticEvent.php
Normal file
64
src/Event/ProjectBudgetStatisticEvent.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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\Event;
|
||||
|
||||
use App\Model\ProjectBudgetStatisticModel;
|
||||
|
||||
final class ProjectBudgetStatisticEvent
|
||||
{
|
||||
private $models;
|
||||
private $begin;
|
||||
private $end;
|
||||
|
||||
/**
|
||||
* @param ProjectBudgetStatisticModel[] $models
|
||||
* @param \DateTime|null $begin
|
||||
* @param \DateTime|null $end
|
||||
*/
|
||||
public function __construct(array $models, ?\DateTime $begin = null, ?\DateTime $end = null)
|
||||
{
|
||||
$this->models = $models;
|
||||
$this->begin = $begin;
|
||||
$this->end = $end;
|
||||
}
|
||||
|
||||
public function getModel(int $projectId): ?ProjectBudgetStatisticModel
|
||||
{
|
||||
if (isset($this->models[$projectId])) {
|
||||
return $this->models[$projectId];
|
||||
}
|
||||
|
||||
foreach ($this->models as $model) {
|
||||
if ($model->getProject()->getId() === $projectId) {
|
||||
return $model;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ProjectBudgetStatisticModel[]
|
||||
*/
|
||||
public function getModels(): array
|
||||
{
|
||||
return $this->models;
|
||||
}
|
||||
|
||||
public function getBegin(): ?\DateTime
|
||||
{
|
||||
return $this->begin;
|
||||
}
|
||||
|
||||
public function getEnd(): ?\DateTime
|
||||
{
|
||||
return $this->end;
|
||||
}
|
||||
}
|
||||
@@ -15,15 +15,29 @@ use App\Model\ProjectStatistic;
|
||||
final class ProjectStatisticEvent extends AbstractProjectEvent
|
||||
{
|
||||
private $statistic;
|
||||
private $begin;
|
||||
private $end;
|
||||
|
||||
public function __construct(Project $project, ProjectStatistic $statistic)
|
||||
public function __construct(Project $project, ProjectStatistic $statistic, \DateTime $begin = null, \DateTime $end = null)
|
||||
{
|
||||
parent::__construct($project);
|
||||
$this->statistic = $statistic;
|
||||
$this->begin = $begin;
|
||||
$this->end = $end;
|
||||
}
|
||||
|
||||
public function getStatistic(): ProjectStatistic
|
||||
{
|
||||
return $this->statistic;
|
||||
}
|
||||
|
||||
public function getBegin(): ?\DateTime
|
||||
{
|
||||
return $this->begin;
|
||||
}
|
||||
|
||||
public function getEnd(): ?\DateTime
|
||||
{
|
||||
return $this->end;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user