fix : wip
This commit is contained in:
@@ -9,6 +9,7 @@ use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
|
||||
use ApiPlatform\Metadata\ApiFilter;
|
||||
use ApiPlatform\Metadata\ApiProperty;
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use App\Repository\AbsenceRepository;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
@@ -26,7 +27,7 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
||||
)]
|
||||
#[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
|
||||
{
|
||||
|
||||
103
src/Entity/Contract.php
Normal file
103
src/Entity/Contract.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
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 = 'TIME';
|
||||
public const string TRACKING_PRESENCE = 'PRESENCE';
|
||||
|
||||
#[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 setTrackingMode(string $trackingMode): self
|
||||
{
|
||||
$this->trackingMode = $trackingMode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
@@ -11,6 +11,8 @@ 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;
|
||||
@@ -26,11 +28,16 @@ use Symfony\Component\Serializer\Attribute\Groups;
|
||||
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]
|
||||
#[ORM\Entity(repositoryClass: WorkHourRepository::class)]
|
||||
#[ORM\Table(name: 'work_hours')]
|
||||
#[ORM\UniqueConstraint(name: 'uniq_work_hours_employee_date', fields: ['employee', 'workDate'])]
|
||||
class WorkHour
|
||||
@@ -75,6 +82,18 @@ class WorkHour
|
||||
#[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;
|
||||
@@ -175,4 +194,55 @@ class WorkHour
|
||||
|
||||
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