Ajout des notification + page employé (#6)
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
| Numéro du ticket | Titre du ticket | |------------------|-----------------| | | | ## Description de la PR ## Modification du .env ## Check list - [ ] Pas de régression - [ ] TU/TI/TF rédigée - [ ] TU/TI/TF OK - [ ] CHANGELOG modifié Reviewed-on: #6 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #6.
This commit is contained in:
@@ -6,6 +6,7 @@ namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use App\Dto\Employees\ContractHistoryItem;
|
||||
use App\Enum\ContractNature;
|
||||
use App\Repository\EmployeeRepository;
|
||||
use App\State\EmployeeWriteProcessor;
|
||||
@@ -74,6 +75,12 @@ class Employee
|
||||
#[Groups(['employee:write'])]
|
||||
private ?string $contractEndDate = null;
|
||||
|
||||
#[Groups(['employee:write'])]
|
||||
private ?bool $contractPaidLeaveSettled = null;
|
||||
|
||||
#[Groups(['employee:write'])]
|
||||
private ?string $contractComment = null;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->createdAt = new DateTimeImmutable();
|
||||
@@ -109,6 +116,15 @@ class Employee
|
||||
return $this;
|
||||
}
|
||||
|
||||
#[Groups(['employee:read'])]
|
||||
public function getInitials(): string
|
||||
{
|
||||
$first = mb_strtoupper(mb_substr(trim($this->firstName), 0, 1));
|
||||
$last = mb_strtoupper(mb_substr(trim($this->lastName), 0, 1));
|
||||
|
||||
return $first.$last;
|
||||
}
|
||||
|
||||
public function getSite(): ?Site
|
||||
{
|
||||
return $this->site;
|
||||
@@ -186,6 +202,30 @@ class Employee
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContractPaidLeaveSettled(): ?bool
|
||||
{
|
||||
return $this->contractPaidLeaveSettled;
|
||||
}
|
||||
|
||||
public function setContractPaidLeaveSettled(?bool $contractPaidLeaveSettled): self
|
||||
{
|
||||
$this->contractPaidLeaveSettled = $contractPaidLeaveSettled;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContractComment(): ?string
|
||||
{
|
||||
return $this->contractComment;
|
||||
}
|
||||
|
||||
public function setContractComment(?string $contractComment): self
|
||||
{
|
||||
$this->contractComment = $contractComment;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
#[Groups(['employee:read'])]
|
||||
public function getCurrentContractNature(): string
|
||||
{
|
||||
@@ -204,6 +244,36 @@ class Employee
|
||||
return $this->resolveCurrentContractPeriod()?->getEndDate()?->format('Y-m-d');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return list<ContractHistoryItem>
|
||||
*/
|
||||
#[Groups(['employee:read'])]
|
||||
public function getContractHistory(): array
|
||||
{
|
||||
$periods = $this->contractPeriods->toArray();
|
||||
usort(
|
||||
$periods,
|
||||
static fn (EmployeeContractPeriod $a, EmployeeContractPeriod $b): int => $b->getStartDate() <=> $a->getStartDate()
|
||||
);
|
||||
|
||||
return array_map(
|
||||
static function (EmployeeContractPeriod $period): ContractHistoryItem {
|
||||
$contract = $period->getContract();
|
||||
|
||||
return new ContractHistoryItem(
|
||||
contractId: $contract?->getId(),
|
||||
contractName: $contract?->getName(),
|
||||
weeklyHours: $contract?->getWeeklyHours(),
|
||||
contractNature: $period->getContractNatureEnum()->value,
|
||||
startDate: $period->getStartDate()->format('Y-m-d'),
|
||||
endDate: $period->getEndDate()?->format('Y-m-d'),
|
||||
comment: $period->getComment(),
|
||||
);
|
||||
},
|
||||
$periods
|
||||
);
|
||||
}
|
||||
|
||||
private function resolveCurrentContractPeriod(): ?EmployeeContractPeriod
|
||||
{
|
||||
$today = new DateTimeImmutable('today');
|
||||
|
||||
Reference in New Issue
Block a user