<?php
namespace App\Entity\Notes;
use App\Entity\Adresses\Adresse;
use App\Entity\Articles\Article;
use App\Entity\Clients\Client;
use App\Entity\Fournisseurs\Fournisseur;
use App\Entity\GestionComerciale\Commande;
use App\Entity\GestionComerciale\CommandeFournisseur;
use App\Entity\Inventaires\Inventaire;
use App\Entity\Kanban\Colonne;
use App\Entity\Kanban\Fiche;
use App\Entity\Projets\Tache;
use App\Entity\Utilisateur\Contact;
use App\Entity\Utilisateur\Utilisateur;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
use App\Annotations\SecuredEntity;
/**
* Note
*
* @ORM\Table("note__note")
* @ORM\Entity(repositoryClass="App\Repository\Notes\NoteRepository")
* @Gedmo\SoftDeleteable(fieldName="dateSuppression",timeAware=false)
* @SecuredEntity(name="Note", group="OUTILS")
*/
class Note
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Articles\Article")
* @ORM\JoinColumn(nullable=true)
* @Assert\Valid
*/
private $article;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Inventaires\Inventaire")
* @ORM\JoinColumn(nullable=true)
* @Assert\Valid
*/
private $inventaire;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\GestionComerciale\CommandeFournisseur")
* @ORM\JoinColumn(nullable=true)
* @Assert\Valid
*/
private $commandeFournisseur;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\GestionComerciale\Commande", inversedBy="notes")
* @ORM\JoinColumn(nullable=true)
* @Assert\Valid
*/
private $commande;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Notes\Note")
* @ORM\JoinColumn(nullable=true)
*/
private $parent;
/**
* @ORM\Column(name="jeton", type="string", length=255, nullable=true)
*/
private $jeton;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Adresses\Adresse")
* @ORM\JoinColumn(nullable=true)
*/
private $adresse;
/**
* @ORM\Column(name="adresse_ville", type="string", length=255, nullable=true)
*/
private $adresseVille;
/**
* @ORM\Column(name="adresse_numero", type="string", length=255, nullable=true)
*/
private $adresseNumero;
/**
* @ORM\Column(name="adresse_rue", type="string", length=255, nullable=true)
*/
private $adresseRue;
/**
* @ORM\Column(name="adresse_cp", type="string", length=255, nullable=true)
*/
private $adresseCp;
/**
* @ORM\Column(name="adresse_complement", type="string", length=255, nullable=true)
*/
private $adresseComplement;
/**
* @ORM\Column(name="adresse_complement2", type="string", length=255, nullable=true)
*/
private $adresseComplement2;
/**
* @ORM\Column(name="libelle", type="string", length=255, nullable=true)
* @Assert\NotBlank(message="Libellé obligatoire")
*/
private $libelle;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Utilisateur", inversedBy="notes")
* @ORM\JoinColumn(nullable=true)
*/
private $utilisateur;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Notes\Categorie")
* @ORM\JoinColumn(nullable=true)
*/
private $categorie;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Notes\Statut")
* @ORM\JoinColumn(nullable=true)
*/
private $statut;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Clients\Client", inversedBy="notes")
* @ORM\JoinColumn(nullable=true)
*/
private $client;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Fournisseurs\Fournisseur")
* @ORM\JoinColumn(nullable=true)
*/
private $fournisseur;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Projets\Tache", inversedBy="interventions")
* @ORM\JoinColumn(nullable=true)
*/
private $tache;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Contact", inversedBy="notes")
* @ORM\JoinColumn(nullable=true)
*/
private $contact;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Contact")
* @ORM\JoinColumn(nullable=true)
*/
private $contactFournisseur;
/**
* @ORM\Column(name="message", type="text", nullable=true)
*/
private $message;
/**
* @ORM\Column(name="finRecurrence", type="datetime", nullable=true)
*/
private $finRecurrence;
/**
* @ORM\Column(name="recurrence", type="string", length=255, nullable=true)
*/
private $recurrence;
/**
* @ORM\Column(name="alerte", type="string", length=255, nullable=true)
*/
private $alerte;
/**
* @ORM\Column(name="date", type="datetime", nullable=true)
*/
private $date;
/**
* @ORM\Column(name="dateSuppression", type="datetime", nullable=true)
*/
private $dateSuppression;
/**
* @ORM\Column(name="dateRappel", type="datetime", nullable=true)
*/
private $dateRappel;
/**
* @ORM\Column(name="dateDebut", type="datetime", nullable=true)
*/
private $dateDebut;
/**
* @ORM\Column(name="dateFin", type="datetime", nullable=true)
*/
private $dateFin;
/**
* @ORM\Column(name="termine", type="boolean", nullable=true)
*/
private $termine;
/**
* @ORM\Column(name="mail_rappel_envoye", type="boolean", nullable=true)
*/
private $mailRappelEnvoye;
/**
* @ORM\Column(name="prive", type="boolean", nullable=true)
*/
private $prive;
/**
* @ORM\Column(name="dateSaisie", type="datetime", nullable=true)
*/
private $dateSaisie;
/**
* @ORM\Column(name="temps_trajet", type="integer", nullable=true)
*/
private $tempsTrajet;
/**
* @ORM\Column(name="id_import", type="string",length=255, nullable=true)
*/
private $idImport;
/**
* @ORM\Column(name="id_import_2", type="string",length=255, nullable=true)
*/
private $idImport2;
/**
* @ORM\Column(name="modifiable", type="boolean", nullable=true)
*/
private $modifiable;
/**
* @ORM\Column(name="date_maj", type="datetime", nullable=true)
* @Gedmo\Timestampable(on="update")
*/
private $dateMaj;
/**
* @ORM\Column(name="date_maj_google", type="datetime", nullable=true)
*/
private $dateMajGoogle;
/**
* @ORM\Column(name="id_fusion", type="integer", nullable=true)
*/
private $idFusion;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Kanban\Fiche" , inversedBy="notes")
* @ORM\JoinColumn(nullable=true)
*/
private $fiche;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Kanban\Colonne")
* @ORM\JoinColumn(nullable=true)
*/
private $colonne;
public function __construct()
{
$this->date = new Datetime();
$this->dateDebut = new Datetime();
$this->dateSaisie = new Datetime();
$this->termine = false;
$this->prive = 0;
$this->jeton = $this->generateRandomString();
}
public function getId(): ?int
{
return $this->id;
}
public function setMessage(?string $message): Note
{
$this->message = $message;
return $this;
}
public function getMessage(): ?string
{
return $this->message;
}
public function setDate(?DateTime $date): Note
{
$this->date = $date;
return $this;
}
public function getDate(): ?DateTime
{
return $this->date;
}
public function setDateSuppression(?DateTime $dateSuppression): Note
{
$this->dateSuppression = $dateSuppression;
return $this;
}
public function getDateSuppression(): ?DateTime
{
return $this->dateSuppression;
}
public function setDateRappel(?DateTime $dateRappel): Note
{
$this->dateRappel = $dateRappel;
return $this;
}
public function getDateRappel(): ?DateTime
{
return $this->dateRappel;
}
public function setTermine(?bool $termine): Note
{
$this->termine = $termine;
return $this;
}
public function getTermine(): ?bool
{
return $this->termine;
}
public function setDateSaisie(?DateTime $dateSaisie): Note
{
$this->dateSaisie = $dateSaisie;
return $this;
}
public function getDateSaisie(): ?DateTime
{
return $this->dateSaisie;
}
public function setUtilisateur(?Utilisateur $utilisateur): Note
{
$this->utilisateur = $utilisateur;
return $this;
}
public function getUtilisateur(): ?Utilisateur
{
return $this->utilisateur;
}
public function setClient(?Client $client): Note
{
$this->client = $client;
return $this;
}
public function getClient(): ?Client
{
return $this->client;
}
public function setContact(?Contact $contact): Note
{
$this->contact = $contact;
return $this;
}
public function getContact(): ?Contact
{
return $this->contact;
}
public function setPrive(?bool $prive): Note
{
$this->prive = $prive;
return $this;
}
public function getPrive(): ?bool
{
return $this->prive;
}
public function setCategorie(?Categorie $categorie): Note
{
$this->categorie = $categorie;
return $this;
}
public function getCategorie(): ?Categorie
{
return $this->categorie;
}
public function setStatut(?Statut $statut): Note
{
$this->statut = $statut;
return $this;
}
public function getStatut(): ?Statut
{
return $this->statut;
}
public function setLibelle(?string $libelle): Note
{
$this->libelle = $libelle;
return $this;
}
public function getLibelle(): ?string
{
return $this->libelle;
}
public function setDateDebut(?DateTime $dateDebut): Note
{
$this->dateDebut = $dateDebut;
return $this;
}
public function getDateDebut(): ?DateTime
{
return $this->dateDebut;
}
public function setDateFin(?DateTime $dateFin): Note
{
$this->dateFin = $dateFin;
return $this;
}
public function getDateFin(): ?DateTime
{
return $this->dateFin;
}
public function setIdImport(?string $idImport): Note
{
$this->idImport = $idImport;
return $this;
}
public function getIdImport(): ?string
{
return $this->idImport;
}
public function getEcheance(): float
{
$now = time();// or your date as well
$your_date = strtotime($this->getDateDebut()->format("Y-m-d"));
$datediff = $your_date-$now;
$tempsRestant = round($datediff / (60 * 60 * 24));
return $tempsRestant;
}
public function setParent(?Note $parent): Note
{
$this->parent = $parent;
return $this;
}
public function getParent(): ?Note
{
return $this->parent;
}
public function setFinRecurrence(?DateTime $finRecurrence): Note
{
$this->finRecurrence = $finRecurrence;
return $this;
}
public function getFinRecurrence(): ?DateTime
{
return $this->finRecurrence;
}
public function setRecurrence(?string $recurrence): Note
{
$this->recurrence = $recurrence;
return $this;
}
public function getRecurrence(): ?string
{
return $this->recurrence;
}
public function setTempsTrajet(?int $tempsTrajet): Note
{
$this->tempsTrajet = $tempsTrajet;
return $this;
}
public function getTempsTrajet(): ?int
{
return $this->tempsTrajet;
}
public function setAlerte(?string $alerte): Note
{
$this->alerte = $alerte;
return $this;
}
public function getAlerte(): ?string
{
return $this->alerte;
}
public function setMailRappelEnvoye(?bool $mailRappelEnvoye): Note
{
$this->mailRappelEnvoye = $mailRappelEnvoye;
return $this;
}
public function getMailRappelEnvoye(): ?bool
{
return $this->mailRappelEnvoye;
}
public function setJeton(?string $jeton): Note
{
$this->jeton = $jeton;
return $this;
}
public function getJeton(): ?string
{
return $this->jeton;
}
public function generateRandomString($length = 30): string
{
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomString .= $characters[rand(0, $charactersLength - 1)];
}
return $randomString;
}
public function setModifiable(?bool $modifiable): Note
{
$this->modifiable = $modifiable;
return $this;
}
public function getModifiable(): ?bool
{
return $this->modifiable;
}
public function setCommandeFournisseur(?CommandeFournisseur $commandeFournisseur): Note
{
$this->commandeFournisseur = $commandeFournisseur;
return $this;
}
public function getCommandeFournisseur(): ?CommandeFournisseur
{
return $this->commandeFournisseur;
}
public function setCommande(?Commande $commande): Note
{
$this->commande = $commande;
return $this;
}
public function getCommande(): ?Commande
{
return $this->commande;
}
public function setFournisseur(?Fournisseur $fournisseur): Note
{
$this->fournisseur = $fournisseur;
return $this;
}
public function getFournisseur(): ?Fournisseur
{
return $this->fournisseur;
}
public function setArticle(?Article $article): Note
{
$this->article = $article;
return $this;
}
public function getArticle(): ?Article
{
return $this->article;
}
public function setInventaire(?Inventaire $inventaire): Note
{
$this->inventaire = $inventaire;
return $this;
}
public function getInventaire(): ?Inventaire
{
return $this->inventaire;
}
public function setDateMaj(?DateTime $dateMaj): Note
{
$this->dateMaj = $dateMaj;
return $this;
}
public function getDateMaj(): ?DateTime
{
return $this->dateMaj;
}
public function setDateMajGoogle(?DateTime $dateMajGoogle): Note
{
$this->dateMajGoogle = $dateMajGoogle;
return $this;
}
public function getDateMajGoogle(): ?DateTime
{
return $this->dateMajGoogle;
}
public function setIdImport2(?string $idImport2): Note
{
$this->idImport2 = $idImport2;
return $this;
}
public function getIdImport2(): ?string
{
return $this->idImport2;
}
public function setAdresseVille(?string $adresseVille): Note
{
$this->adresseVille = $adresseVille;
return $this;
}
public function getAdresseVille(): ?string
{
return $this->adresseVille;
}
public function setAdresseNumero(?string $adresseNumero): Note
{
$this->adresseNumero = $adresseNumero;
return $this;
}
public function getAdresseNumero(): ?string
{
return $this->adresseNumero;
}
public function setAdresseRue(?string $adresseRue): Note
{
$this->adresseRue = $adresseRue;
return $this;
}
public function getAdresseRue(): ?string
{
return $this->adresseRue;
}
public function setAdresseCp(?string $adresseCp): Note
{
$this->adresseCp = $adresseCp;
return $this;
}
public function getAdresseCp(): ?string
{
return $this->adresseCp;
}
public function setAdresseComplement(?string $adresseComplement): Note
{
$this->adresseComplement = $adresseComplement;
return $this;
}
public function getAdresseComplement(): ?string
{
return $this->adresseComplement;
}
public function setAdresseComplement2(?string $adresseComplement2): Note
{
$this->adresseComplement2 = $adresseComplement2;
return $this;
}
public function getAdresseComplement2(): ?string
{
return $this->adresseComplement2;
}
public function setAdresse(?Adresse $adresse): Note
{
$this->adresse = $adresse;
return $this;
}
public function getAdresse(): ?Adresse
{
return $this->adresse;
}
public function setIdFusion(?int $idFusion): Note
{
$this->idFusion = $idFusion;
return $this;
}
public function getIdFusion(): ?int
{
return $this->idFusion;
}
public function setContactFournisseur(?Contact $contactFournisseur): Note
{
$this->contactFournisseur = $contactFournisseur;
return $this;
}
public function getContactFournisseur(): ?Contact
{
return $this->contactFournisseur;
}
public function setFiche(?Fiche $fiche): Note
{
$this->fiche = $fiche;
return $this;
}
public function getFiche(): ?Fiche
{
return $this->fiche;
}
public function setColonne(?Colonne $colonne): Note
{
$this->colonne = $colonne;
return $this;
}
public function getColonne(): ?Colonne
{
return $this->colonne;
}
public function getTache(): ?Tache
{
return $this->tache;
}
public function setTache(?Tache $tache): Note
{
$this->tache = $tache;
return $this;
}
}