| Numéro du ticket | Titre du ticket | |------------------|-----------------| | #322 | Page horaire | ## Description de la PR [#322] Page horaire ## Modification du .env ## Check list - [ ] Pas de régression - [ ] TU/TI/TF rédigée - [ ] TU/TI/TF OK - [ ] CHANGELOG modifié Reviewed-on: #4 Co-authored-by: tristan <tristan@yuno.malio.fr> Co-committed-by: tristan <tristan@yuno.malio.fr>
This commit was merged in pull request #4.
This commit is contained in:
@@ -9,11 +9,39 @@ use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
|
||||
use ApiPlatform\Metadata\ApiFilter;
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Delete;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use ApiPlatform\Metadata\Patch;
|
||||
use ApiPlatform\Metadata\Post;
|
||||
use App\Enum\HalfDay;
|
||||
use App\Repository\AbsenceRepository;
|
||||
use App\State\AbsenceWriteProcessor;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new GetCollection(
|
||||
security: "is_granted('ROLE_USER')"
|
||||
),
|
||||
new Get(
|
||||
security: "is_granted('ABSENCE_VIEW', object)"
|
||||
),
|
||||
new Post(
|
||||
securityPostDenormalize: "is_granted('ABSENCE_EDIT', object)",
|
||||
processor: AbsenceWriteProcessor::class
|
||||
),
|
||||
new Patch(
|
||||
security: "is_granted('ABSENCE_EDIT', object)",
|
||||
processor: AbsenceWriteProcessor::class
|
||||
),
|
||||
new Delete(
|
||||
security: "is_granted('ABSENCE_EDIT', object)",
|
||||
processor: AbsenceWriteProcessor::class
|
||||
),
|
||||
],
|
||||
normalizationContext: [
|
||||
'groups' => ['absence:read', 'employee:read', 'absence_type:read'],
|
||||
'datetime_format' => 'Y-m-d',
|
||||
@@ -22,11 +50,10 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
||||
'datetime_format' => 'Y-m-d',
|
||||
],
|
||||
paginationEnabled: false,
|
||||
security: "is_granted('ROLE_ADMIN')",
|
||||
)]
|
||||
#[ApiFilter(DateFilter::class, properties: ['startDate', 'endDate'])]
|
||||
#[ApiFilter(SearchFilter::class, properties: ['employee.site' => 'exact'])]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Entity(repositoryClass: AbsenceRepository::class)]
|
||||
#[ORM\Table(name: 'absences')]
|
||||
class Absence
|
||||
{
|
||||
@@ -52,17 +79,17 @@ class Absence
|
||||
#[Groups(['absence:read'])]
|
||||
private DateTimeInterface $startDate;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 2, options: ['default' => 'AM'])]
|
||||
#[ORM\Column(type: 'string', length: 2, enumType: HalfDay::class, options: ['default' => 'AM'])]
|
||||
#[Groups(['absence:read'])]
|
||||
private string $startHalf = 'AM';
|
||||
private HalfDay $startHalf = HalfDay::AM;
|
||||
|
||||
#[ORM\Column(type: 'date')]
|
||||
#[Groups(['absence:read'])]
|
||||
private DateTimeInterface $endDate;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 2, options: ['default' => 'PM'])]
|
||||
#[ORM\Column(type: 'string', length: 2, enumType: HalfDay::class, options: ['default' => 'PM'])]
|
||||
#[Groups(['absence:read'])]
|
||||
private string $endHalf = 'PM';
|
||||
private HalfDay $endHalf = HalfDay::PM;
|
||||
|
||||
#[ORM\Column(type: 'text', nullable: true)]
|
||||
#[Groups(['absence:read'])]
|
||||
@@ -121,24 +148,24 @@ class Absence
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getStartHalf(): string
|
||||
public function getStartHalf(): HalfDay
|
||||
{
|
||||
return $this->startHalf;
|
||||
}
|
||||
|
||||
public function setStartHalf(string $startHalf): self
|
||||
public function setStartHalf(HalfDay $startHalf): self
|
||||
{
|
||||
$this->startHalf = $startHalf;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEndHalf(): string
|
||||
public function getEndHalf(): HalfDay
|
||||
{
|
||||
return $this->endHalf;
|
||||
}
|
||||
|
||||
public function setEndHalf(string $endHalf): self
|
||||
public function setEndHalf(HalfDay $endHalf): self
|
||||
{
|
||||
$this->endHalf = $endHalf;
|
||||
|
||||
|
||||
@@ -5,13 +5,34 @@ declare(strict_types=1);
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Delete;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use ApiPlatform\Metadata\Patch;
|
||||
use ApiPlatform\Metadata\Post;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new GetCollection(
|
||||
security: "is_granted('ROLE_USER')"
|
||||
),
|
||||
new Get(
|
||||
security: "is_granted('ROLE_USER')"
|
||||
),
|
||||
new Post(
|
||||
security: "is_granted('ROLE_ADMIN')"
|
||||
),
|
||||
new Patch(
|
||||
security: "is_granted('ROLE_ADMIN')"
|
||||
),
|
||||
new Delete(
|
||||
security: "is_granted('ROLE_ADMIN')"
|
||||
),
|
||||
],
|
||||
normalizationContext: ['groups' => ['absence_type:read']],
|
||||
paginationEnabled: false,
|
||||
security: "is_granted('ROLE_ADMIN')"
|
||||
)]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'absence_types')]
|
||||
@@ -35,6 +56,10 @@ class AbsenceType
|
||||
#[Groups(['absence:read', 'absence_type:read'])]
|
||||
private string $color = '';
|
||||
|
||||
#[ORM\Column(type: 'boolean', options: ['default' => false])]
|
||||
#[Groups(['absence:read', 'absence_type:read'])]
|
||||
private bool $countAsWorkedHours = false;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
@@ -75,4 +100,21 @@ class AbsenceType
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isCountAsWorkedHours(): bool
|
||||
{
|
||||
return $this->countAsWorkedHours;
|
||||
}
|
||||
|
||||
public function getCountAsWorkedHours(): bool
|
||||
{
|
||||
return $this->countAsWorkedHours;
|
||||
}
|
||||
|
||||
public function setCountAsWorkedHours(bool $countAsWorkedHours): self
|
||||
{
|
||||
$this->countAsWorkedHours = $countAsWorkedHours;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
122
src/Entity/Contract.php
Normal file
122
src/Entity/Contract.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use App\Enum\ContractType;
|
||||
use App\Enum\TrackingMode;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use InvalidArgumentException;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ApiResource(
|
||||
normalizationContext: ['groups' => ['contract:read']],
|
||||
denormalizationContext: ['groups' => ['contract:write']],
|
||||
paginationEnabled: false,
|
||||
security: "is_granted('ROLE_ADMIN')"
|
||||
)]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Table(name: 'contracts')]
|
||||
class Contract
|
||||
{
|
||||
public const string TRACKING_TIME = TrackingMode::TIME->value;
|
||||
public const string TRACKING_PRESENCE = TrackingMode::PRESENCE->value;
|
||||
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: 'integer')]
|
||||
#[Groups(['contract:read', 'employee:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 120)]
|
||||
#[Groups(['contract:read', 'contract:write', 'employee:read'])]
|
||||
private string $name = '';
|
||||
|
||||
#[ORM\Column(type: 'string', length: 20)]
|
||||
#[Groups(['contract:read', 'contract:write', 'employee:read'])]
|
||||
private string $trackingMode = self::TRACKING_TIME;
|
||||
|
||||
#[ORM\Column(type: 'integer', nullable: true)]
|
||||
#[Groups(['contract:read', 'contract:write', 'employee:read'])]
|
||||
private ?int $weeklyHours = null;
|
||||
|
||||
#[ORM\Column(type: 'boolean', options: ['default' => true])]
|
||||
#[Groups(['contract:read', 'contract:write'])]
|
||||
private bool $isActive = true;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
public function setName(string $name): self
|
||||
{
|
||||
$this->name = $name;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTrackingMode(): string
|
||||
{
|
||||
return $this->trackingMode;
|
||||
}
|
||||
|
||||
public function getTrackingModeEnum(): TrackingMode
|
||||
{
|
||||
return TrackingMode::tryFrom($this->trackingMode) ?? TrackingMode::TIME;
|
||||
}
|
||||
|
||||
public function setTrackingMode(string|TrackingMode $trackingMode): self
|
||||
{
|
||||
$value = $trackingMode instanceof TrackingMode ? $trackingMode->value : $trackingMode;
|
||||
if (null === TrackingMode::tryFrom($value)) {
|
||||
throw new InvalidArgumentException(sprintf('Invalid tracking mode "%s".', $value));
|
||||
}
|
||||
|
||||
$this->trackingMode = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
#[Groups(['contract:read', 'employee:read'])]
|
||||
public function getType(): ContractType
|
||||
{
|
||||
return ContractType::resolve($this->name, $this->trackingMode, $this->weeklyHours);
|
||||
}
|
||||
|
||||
public function getWeeklyHours(): ?int
|
||||
{
|
||||
return $this->weeklyHours;
|
||||
}
|
||||
|
||||
public function setWeeklyHours(?int $weeklyHours): self
|
||||
{
|
||||
$this->weeklyHours = $weeklyHours;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isActive(): bool
|
||||
{
|
||||
return $this->isActive;
|
||||
}
|
||||
|
||||
public function getIsActive(): bool
|
||||
{
|
||||
return $this->isActive;
|
||||
}
|
||||
|
||||
public function setIsActive(bool $isActive): self
|
||||
{
|
||||
$this->isActive = $isActive;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use App\Repository\EmployeeRepository;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
@@ -15,7 +17,7 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
||||
paginationEnabled: false,
|
||||
security: "is_granted('ROLE_ADMIN')"
|
||||
)]
|
||||
#[ORM\Entity]
|
||||
#[ORM\Entity(repositoryClass: EmployeeRepository::class)]
|
||||
#[ORM\Table(name: 'employees')]
|
||||
class Employee
|
||||
{
|
||||
@@ -33,12 +35,18 @@ class Employee
|
||||
#[Groups(['absence:read', 'employee:read', 'employee:write'])]
|
||||
private string $lastName = '';
|
||||
|
||||
#[ApiPlatform\Metadata\ApiProperty(readableLink: true)]
|
||||
#[ApiProperty(readableLink: true)]
|
||||
#[ORM\ManyToOne(targetEntity: Site::class)]
|
||||
#[ORM\JoinColumn(nullable: true)]
|
||||
#[Groups(['employee:read', 'employee:write'])]
|
||||
private ?Site $site = null;
|
||||
|
||||
#[ApiProperty(readableLink: true)]
|
||||
#[ORM\ManyToOne(targetEntity: Contract::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[Groups(['employee:read', 'employee:write'])]
|
||||
private ?Contract $contract = null;
|
||||
|
||||
#[ORM\Column(type: 'integer', options: ['default' => 0])]
|
||||
#[Groups(['employee:read', 'employee:write'])]
|
||||
private int $displayOrder = 0;
|
||||
@@ -92,6 +100,18 @@ class Employee
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getContract(): ?Contract
|
||||
{
|
||||
return $this->contract;
|
||||
}
|
||||
|
||||
public function setContract(?Contract $contract): self
|
||||
{
|
||||
$this->contract = $contract;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCreatedAt(): DateTimeImmutable
|
||||
{
|
||||
return $this->createdAt;
|
||||
|
||||
248
src/Entity/WorkHour.php
Normal file
248
src/Entity/WorkHour.php
Normal file
@@ -0,0 +1,248 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
|
||||
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
|
||||
use ApiPlatform\Metadata\ApiFilter;
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\GetCollection;
|
||||
use ApiPlatform\Metadata\Patch;
|
||||
use App\Repository\WorkHourRepository;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new GetCollection(
|
||||
paginationEnabled: false,
|
||||
normalizationContext: ['groups' => ['work_hour:read', 'employee:read', 'site:read']],
|
||||
security: "is_granted('ROLE_USER')"
|
||||
),
|
||||
new Get(
|
||||
normalizationContext: ['groups' => ['work_hour:read', 'employee:read', 'site:read']],
|
||||
security: "is_granted('WORK_HOUR_VIEW', object)"
|
||||
),
|
||||
new Patch(
|
||||
normalizationContext: ['groups' => ['work_hour:read', 'employee:read', 'site:read']],
|
||||
denormalizationContext: ['groups' => ['work_hour:validate']],
|
||||
security: "is_granted('ROLE_ADMIN')"
|
||||
),
|
||||
],
|
||||
)]
|
||||
#[ApiFilter(DateFilter::class, properties: ['workDate'])]
|
||||
#[ApiFilter(SearchFilter::class, properties: ['employee' => 'exact', 'employee.site' => 'exact'])]
|
||||
#[ORM\Entity(repositoryClass: WorkHourRepository::class)]
|
||||
#[ORM\Table(name: 'work_hours')]
|
||||
#[ORM\UniqueConstraint(name: 'uniq_work_hours_employee_date', fields: ['employee', 'workDate'])]
|
||||
class WorkHour
|
||||
{
|
||||
#[ORM\Id]
|
||||
#[ORM\GeneratedValue]
|
||||
#[ORM\Column(type: 'integer')]
|
||||
#[Groups(['work_hour:read'])]
|
||||
private ?int $id = null;
|
||||
|
||||
#[ApiProperty(readableLink: true)]
|
||||
#[ORM\ManyToOne(targetEntity: Employee::class)]
|
||||
#[ORM\JoinColumn(nullable: false)]
|
||||
#[Groups(['work_hour:read'])]
|
||||
private ?Employee $employee = null;
|
||||
|
||||
#[ORM\Column(type: 'date_immutable')]
|
||||
#[Groups(['work_hour:read'])]
|
||||
private DateTimeInterface $workDate;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 5, nullable: true)]
|
||||
#[Groups(['work_hour:read'])]
|
||||
private ?string $morningFrom = null;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 5, nullable: true)]
|
||||
#[Groups(['work_hour:read'])]
|
||||
private ?string $morningTo = null;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 5, nullable: true)]
|
||||
#[Groups(['work_hour:read'])]
|
||||
private ?string $afternoonFrom = null;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 5, nullable: true)]
|
||||
#[Groups(['work_hour:read'])]
|
||||
private ?string $afternoonTo = null;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 5, nullable: true)]
|
||||
#[Groups(['work_hour:read'])]
|
||||
private ?string $eveningFrom = null;
|
||||
|
||||
#[ORM\Column(type: 'string', length: 5, nullable: true)]
|
||||
#[Groups(['work_hour:read'])]
|
||||
private ?string $eveningTo = null;
|
||||
|
||||
#[ORM\Column(type: 'boolean', options: ['default' => false])]
|
||||
#[Groups(['work_hour:read'])]
|
||||
private bool $isPresentMorning = false;
|
||||
|
||||
#[ORM\Column(type: 'boolean', options: ['default' => false])]
|
||||
#[Groups(['work_hour:read'])]
|
||||
private bool $isPresentAfternoon = false;
|
||||
|
||||
#[ORM\Column(type: 'boolean', options: ['default' => false])]
|
||||
#[Groups(['work_hour:read', 'work_hour:validate'])]
|
||||
private bool $isValid = false;
|
||||
|
||||
public function getId(): ?int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function getEmployee(): ?Employee
|
||||
{
|
||||
return $this->employee;
|
||||
}
|
||||
|
||||
public function setEmployee(?Employee $employee): self
|
||||
{
|
||||
$this->employee = $employee;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWorkDate(): DateTimeInterface
|
||||
{
|
||||
return $this->workDate;
|
||||
}
|
||||
|
||||
public function setWorkDate(DateTimeInterface $workDate): self
|
||||
{
|
||||
$this->workDate = $workDate;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMorningFrom(): ?string
|
||||
{
|
||||
return $this->morningFrom;
|
||||
}
|
||||
|
||||
public function setMorningFrom(?string $morningFrom): self
|
||||
{
|
||||
$this->morningFrom = $morningFrom;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getMorningTo(): ?string
|
||||
{
|
||||
return $this->morningTo;
|
||||
}
|
||||
|
||||
public function setMorningTo(?string $morningTo): self
|
||||
{
|
||||
$this->morningTo = $morningTo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAfternoonFrom(): ?string
|
||||
{
|
||||
return $this->afternoonFrom;
|
||||
}
|
||||
|
||||
public function setAfternoonFrom(?string $afternoonFrom): self
|
||||
{
|
||||
$this->afternoonFrom = $afternoonFrom;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAfternoonTo(): ?string
|
||||
{
|
||||
return $this->afternoonTo;
|
||||
}
|
||||
|
||||
public function setAfternoonTo(?string $afternoonTo): self
|
||||
{
|
||||
$this->afternoonTo = $afternoonTo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEveningFrom(): ?string
|
||||
{
|
||||
return $this->eveningFrom;
|
||||
}
|
||||
|
||||
public function setEveningFrom(?string $eveningFrom): self
|
||||
{
|
||||
$this->eveningFrom = $eveningFrom;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEveningTo(): ?string
|
||||
{
|
||||
return $this->eveningTo;
|
||||
}
|
||||
|
||||
public function setEveningTo(?string $eveningTo): self
|
||||
{
|
||||
$this->eveningTo = $eveningTo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isPresentMorning(): bool
|
||||
{
|
||||
return $this->isPresentMorning;
|
||||
}
|
||||
|
||||
public function getIsPresentMorning(): bool
|
||||
{
|
||||
return $this->isPresentMorning;
|
||||
}
|
||||
|
||||
public function setIsPresentMorning(bool $isPresentMorning): self
|
||||
{
|
||||
$this->isPresentMorning = $isPresentMorning;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isPresentAfternoon(): bool
|
||||
{
|
||||
return $this->isPresentAfternoon;
|
||||
}
|
||||
|
||||
public function getIsPresentAfternoon(): bool
|
||||
{
|
||||
return $this->isPresentAfternoon;
|
||||
}
|
||||
|
||||
public function setIsPresentAfternoon(bool $isPresentAfternoon): self
|
||||
{
|
||||
$this->isPresentAfternoon = $isPresentAfternoon;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isValid(): bool
|
||||
{
|
||||
return $this->isValid;
|
||||
}
|
||||
|
||||
public function getIsValid(): bool
|
||||
{
|
||||
return $this->isValid;
|
||||
}
|
||||
|
||||
public function setIsValid(bool $isValid): self
|
||||
{
|
||||
$this->isValid = $isValid;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user