Skip to content

Commit

Permalink
add createBy in suivi #3307
Browse files Browse the repository at this point in the history
  • Loading branch information
numew committed Dec 10, 2024
1 parent 9adf73e commit c9be2fe
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Dto/Api/Model/Suivi.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Suivi
public string $description;
public bool $public;
public int $type;
public string $createdBy;

public function __construct(
SuiviEntity $suivi,
Expand All @@ -19,7 +20,7 @@ public function __construct(
$this->dateCreation = $suivi->getCreatedAt()->format(\DATE_ATOM);
$this->description = $suivi->getDescription(); // traitement de suppression du html ? comment gérer les bouton/doc qui sont présent en dur dans le contenu ?
$this->public = $suivi->getIsPublic();
$this->type = $suivi->getType(); // envoyer un libellé ?
// TODO : exposer "createdBy" attendre merge multi ter. et essayer de faire propre
$this->type = $suivi->getType();
$this->createdBy = $suivi->getCreatedByLabel();
}
}
34 changes: 34 additions & 0 deletions src/Entity/Suivi.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,40 @@ public function setCreatedBy(?User $createdBy): self
return $this;
}

public function getCreatedByLabel(): ?string
{
if (self::TYPE_TECHNICAL === $this->type) {
return 'Suivi automatique';
}
if ($this->getCreatedBy()) {
if (in_array('ROLE_USAGER', $this->getCreatedBy()->getRoles())) {
if ($this->getCreatedBy()->getEmail() === $this->getSignalement()->getMailOccupant()) {
return 'OCCUPANT : '.ucfirst($this->getCreatedBy()->getNomComplet());
}

return 'DECLARANT : '.ucfirst($this->getCreatedBy()->getNomComplet());
}
if ($this->getCreatedBy()->getPartnerInTerritoryOrFirstOne($this->getSignalement()->getTerritory())) {
$partner = $this->getCreatedBy()->getPartnerInTerritoryOrFirstOne($this->getSignalement()->getTerritory());
if ($partner->getIsArchive()) {
return 'Partenaire supprimé';
}

return $partner->getNom().' : '.$this->getCreatedBy()->getPrenom().' '.$this->getCreatedBy()->getNom();
}

return 'Aucun';
}
if ($this->getCreatedAt()->format('Y') >= 2024) {
return 'Occupant ou déclarant';
}
if ($this->getSignalement()->getIsNotOccupant()) {
return 'DECLARANT : '.strtoupper($this->getSignalement()->getNomDeclarant()).' '.ucfirst($this->getSignalement()->getPrenomDeclarant());
}

return 'OCCUPANT : '.strtoupper($this->getSignalement()->getNomOccupant()).' '.ucfirst($this->getSignalement()->getPrenomOccupant());
}

public function getDescription($transformHtml = true): ?string
{
if (null !== $this->deletedAt) {
Expand Down

0 comments on commit c9be2fe

Please sign in to comment.