<?php
namespace App\Entity;
use App\Repository\QualificationLevelRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use ApiPlatform\Core\Annotation\ApiResource;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ApiResource(
* security= "is_granted('ROLE_AGENT') or is_granted('ROLE_MANAGER')",
* normalizationContext={"groups"={"qualification-level:read"}, "swagger_definition_name"="Read"},
* denormalizationContext={"groups"={"qualification-level:write"}, "swagger_definition_name"="Write"},
* itemOperations={
* "get"
* },
* collectionOperations={
* "get",
* },
* attributes={
* "pagination_items_per_page"=10,
* "formats"={"jsonld", "json", "html", "jsonhal", "csv"={"text/csv"} }
* }
* )
* @ORM\Entity(repositoryClass=QualificationLevelRepository::class)
*/
class QualificationLevel
{
public const REFERENCE_MANAGER_STARTER_LABEL_COLOR = 'none';
public const REFERENCE_MANAGER_STARTER_LABEL = 'reference.qualification.STARTER';
public const REFERENCE_MANAGER_BRONZE_LABEL = 'reference.qualification.BRONZE';
public const REFERENCE_MANAGER_SILVER_STATUS_LABEL = 'reference.qualification.SILVER';
public const REFERENCE_MANAGER_GOLD_LABEL = 'reference.qualification.GOLD';
public const REFERENCE_MANAGER_PLATINUM_LABEL = 'reference.qualification.PLATINUM';
public const REFERENCE_MANAGER_DIAMOND_LABEL = 'reference.qualification.DIAMOND';
public const REFERENCE_CODE_LEVEL_ZERO = '0';
public const REFERENCE_CODE_LEVEL_ONE = '1';
public const REFERENCE_CODE_LEVEL_TWO = '2';
public const REFERENCE_CODE_LEVEL_THREE = '3';
public const REFERENCE_CODE_LEVEL_FOUR = '4';
public const REFERENCE_CODE_LEVEL_FIVE = '5';
public const REFERENCE_STARTER_GOAL = 0;
public const REFERENCE_BRONZE_GOAL = 300000;
public const REFERENCE_SILVER_GOAL = 250000;
public const REFERENCE_GOLD_GOAL = 200000;
public const REFERENCE_PLATINUM_GOAL = 150000;
public const REFERENCE_DIAMOND_GOAL = 75000;
public const REFERENCE_STARTER_MAX_SPONSORSHIP_REQUEST = -1;
public const REFERENCE_BRONZE_MAX_SPONSORSHIP_REQUEST = 5;
public const REFERENCE_SILVER_MAX_SPONSORSHIP_REQUEST = 10;
public const REFERENCE_GOLD_MAX_SPONSORSHIP_REQUEST = 15;
public const REFERENCE_PLATINUM_MAX_SPONSORSHIP_REQUEST = 0;
public const REFERENCE_DIAMOND_MAX_SPONSORSHIP_REQUEST = 0;
public const RECURRENCE_0 = '0';
public const RECURRENCE_0_2 = '0.2';
public const RECURRENCE_0_5 = '0.5';
public const RECURRENCE_1_5 = '1.5';
public const RECURRENCE_3_0 = '3.0';
public const RECURRENCE_7_0 = '7.0';
public const MAX_LEVEL = '5';
public const ALL_QUALIFICATION_LABELS = [
self::REFERENCE_MANAGER_STARTER_LABEL,
self::REFERENCE_MANAGER_BRONZE_LABEL,
self::REFERENCE_MANAGER_SILVER_STATUS_LABEL,
self::REFERENCE_MANAGER_GOLD_LABEL,
self::REFERENCE_MANAGER_PLATINUM_LABEL,
self::REFERENCE_MANAGER_DIAMOND_LABEL,
];
public const QUALIFICATION_LEVEL_COLORS = [
self::REFERENCE_MANAGER_STARTER_LABEL => self::REFERENCE_MANAGER_STARTER_LABEL_COLOR,
self::REFERENCE_MANAGER_BRONZE_LABEL => '#C1865D',
self::REFERENCE_MANAGER_SILVER_STATUS_LABEL => '#7c7373',
self::REFERENCE_MANAGER_GOLD_LABEL => '#eb9517',
self::REFERENCE_MANAGER_PLATINUM_LABEL => '#326B62',
self::REFERENCE_MANAGER_DIAMOND_LABEL => '#14b3d7',
];
public const ALL_MAX_SPONSORSHIP_REQUEST = [
self::REFERENCE_STARTER_MAX_SPONSORSHIP_REQUEST,
self::REFERENCE_BRONZE_MAX_SPONSORSHIP_REQUEST,
self::REFERENCE_SILVER_MAX_SPONSORSHIP_REQUEST,
self::REFERENCE_GOLD_MAX_SPONSORSHIP_REQUEST,
self::REFERENCE_PLATINUM_MAX_SPONSORSHIP_REQUEST,
self::REFERENCE_DIAMOND_MAX_SPONSORSHIP_REQUEST
];
public const ALL_LEVELS = [
self::REFERENCE_CODE_LEVEL_ZERO,
self::REFERENCE_CODE_LEVEL_ONE,
self::REFERENCE_CODE_LEVEL_TWO,
self::REFERENCE_CODE_LEVEL_THREE,
self::REFERENCE_CODE_LEVEL_FOUR,
self::REFERENCE_CODE_LEVEL_FIVE
];
public const ALL_RECURENCES = [
self::RECURRENCE_0,
self::RECURRENCE_7_0,
self::RECURRENCE_3_0,
self::RECURRENCE_1_5,
self::RECURRENCE_0_5,
self::RECURRENCE_0_2,
];
public const ALL_QUALIFICATION_GOALS = [
self::REFERENCE_STARTER_GOAL,
self::REFERENCE_BRONZE_GOAL,
self::REFERENCE_SILVER_GOAL,
self::REFERENCE_GOLD_GOAL,
self::REFERENCE_PLATINUM_GOAL,
self::REFERENCE_DIAMOND_GOAL
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
* @Groups({
* "collaborator:read",
* "genealogy:read",
* "abstract-colloborator:read",
* "directory:collaborator:search",
* "qualification-level:read",
* "agent:read"
* })
*/
private $id;
/**
* @ORM\Column(type="integer")
* @Groups({
* "collaborator:read",
* "abstract-colloborator:read",
* "directory:collaborator:search",
* "agent:read",
* "milkiya:read"
* })
*/
private ?int $level;
/**
* @ORM\Column(type="float")
* @Groups({
* "collaborator:read",
* "abstract-colloborator:read",
* "directory:collaborator:search",
* "qualification-level:read",
* "agent:read"
* })
*/
private ?float $recurrence;
/**
* @ORM\Column(type="string", length=255)
* @Groups({
* "collaborator:read",
* "candidate:read",
* "genealogy:read",
* "abstract-colloborator:read",
* "directory:collaborator:search",
* "qualification-level:read",
* "agent:read",
* "milkiya:read"
* })
*/
private ?string $label;
/**
* @ORM\OneToMany(targetEntity=Agent::class, mappedBy="qualificationLevel")
*
*/
private $collaborators;
/**
* @ORM\Column(type="integer")
*
* @Groups({
* "collaborator:read",
* "abstract-colloborator:read",
* "directory:collaborator:search",
* "qualification-level:read",
* "agent:read"
* })
*/
private ?int $qualificationLevelGoal;
/**
* @ORM\Column(type="integer",nullable=true)
* @Groups({
* "collaborator:read",
* "abstract-colloborator:read",
* "directory:collaborator:search",
* "qualification-level:read",
* "agent:read"
* })
*/
private ?int $maxSponsorshipRequest;
public function __construct()
{
$this->collaborators = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getLevel(): ?int
{
return $this->level;
}
public function setLevel(int $level): self
{
$this->level = $level;
return $this;
}
public function getRecurrence(): ?float
{
return $this->recurrence;
}
public function setRecurrence(float $recurrence): self
{
$this->recurrence = $recurrence;
return $this;
}
public function getLabel(): ?string
{
return $this->label;
}
public function setLabel(string $label): self
{
$this->label = $label;
return $this;
}
/**
* @return Collection|Agent[]
*/
public function getCollaborators(): Collection
{
return $this->collaborators;
}
public function addCollaborator(Agent $collaborator): self
{
if (!$this->collaborators->contains($collaborator)) {
$this->collaborators[] = $collaborator;
$collaborator->setQualificationLevel($this);
}
return $this;
}
public function removeCollaborator(Agent $collaborator): self
{
// set the owning side to null (unless already changed)
if ($this->collaborators->removeElement($collaborator) && $collaborator->getQualificationLevel() === $this) {
$collaborator->setQualificationLevel(null);
}
return $this;
}
public function getQualificationLevelGoal(): ?int
{
return $this->qualificationLevelGoal;
}
public function setQualificationLevelGoal(int $qualificationLevelGoal): self
{
$this->qualificationLevelGoal = $qualificationLevelGoal;
return $this;
}
public function getMaxSponsorshipRequest(): ?int
{
return $this->maxSponsorshipRequest;
}
public function setMaxSponsorshipRequest(?int $maxSponsorshipRequest): self
{
$this->maxSponsorshipRequest = $maxSponsorshipRequest;
return $this;
}
}