feat : ajout des demi-journées d'absence dans le calendrier et l'export pdf
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
Some checks failed
Auto Tag Develop / tag (push) Has been cancelled
This commit is contained in:
@@ -50,10 +50,18 @@ class Absence
|
||||
#[Groups(['absence:read'])]
|
||||
private DateTimeInterface $startDate;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 2, options: ['default' => 'AM'])]
|
||||
#[Groups(['absence:read'])]
|
||||
private string $startHalf = 'AM';
|
||||
|
||||
#[ORM\Column(type: 'date')]
|
||||
#[Groups(['absence:read'])]
|
||||
private DateTimeInterface $endDate;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 2, options: ['default' => 'PM'])]
|
||||
#[Groups(['absence:read'])]
|
||||
private string $endHalf = 'PM';
|
||||
|
||||
#[ORM\Column(type: 'text', nullable: true)]
|
||||
#[Groups(['absence:read'])]
|
||||
private ?string $comment = null;
|
||||
@@ -111,6 +119,30 @@ class Absence
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStartHalf(): string
|
||||
{
|
||||
return $this->startHalf;
|
||||
}
|
||||
|
||||
public function setStartHalf(string $startHalf): self
|
||||
{
|
||||
$this->startHalf = $startHalf;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEndHalf(): string
|
||||
{
|
||||
return $this->endHalf;
|
||||
}
|
||||
|
||||
public function setEndHalf(string $endHalf): self
|
||||
{
|
||||
$this->endHalf = $endHalf;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getComment(): ?string
|
||||
{
|
||||
return $this->comment;
|
||||
|
||||
@@ -184,17 +184,38 @@ class AbsencePrintProvider implements ProviderInterface
|
||||
|
||||
$absenceStart = DateTimeImmutable::createFromInterface($absence->getStartDate());
|
||||
$absenceEnd = DateTimeImmutable::createFromInterface($absence->getEndDate());
|
||||
$startHalf = $absence->getStartHalf();
|
||||
$endHalf = $absence->getEndHalf();
|
||||
|
||||
$start = max($absenceStart, $from);
|
||||
$end = min($absenceEnd, $to);
|
||||
|
||||
$current = $start;
|
||||
while ($current <= $end) {
|
||||
$dateKey = $current->format('Y-m-d');
|
||||
$dateKey = $current->format('Y-m-d');
|
||||
$isSameDay = $absenceStart->format('Y-m-d') === $absenceEnd->format('Y-m-d');
|
||||
$isStartDay = $current->format('Y-m-d') === $absenceStart->format('Y-m-d');
|
||||
$isEndDay = $current->format('Y-m-d') === $absenceEnd->format('Y-m-d');
|
||||
$halfLabel = null;
|
||||
|
||||
if ($isSameDay) {
|
||||
if ($startHalf === $endHalf) {
|
||||
$halfLabel = $startHalf;
|
||||
}
|
||||
} else {
|
||||
if ($isStartDay && 'PM' === $startHalf) {
|
||||
$halfLabel = 'PM';
|
||||
}
|
||||
if ($isEndDay && 'AM' === $endHalf) {
|
||||
$halfLabel = 'AM';
|
||||
}
|
||||
}
|
||||
|
||||
$map[$employeeId][$dateKey] = [
|
||||
'code' => (string) $type->getCode(),
|
||||
'color' => (string) $type->getColor(),
|
||||
'code' => (string) $type->getCode(),
|
||||
'color' => (string) $type->getColor(),
|
||||
'half' => null !== $halfLabel,
|
||||
'halfLabel' => $halfLabel,
|
||||
];
|
||||
|
||||
$current = $current->add(new DateInterval('P1D'));
|
||||
|
||||
Reference in New Issue
Block a user