<?php
namespace App\Entity;
use App\Repository\ContratRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ContratRepository::class)
*/
class Contrat
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Tiers::class, inversedBy="contrats")
* @ORM\JoinColumn(nullable=true)
*/
private $salarie;
/**
* @ORM\Column(type="integer")
*/
private $nb_jour_pointage;
/**
* @ORM\Column(type="float")
*/
private $tarif_jour;
/**
* @ORM\Column(type="float")
*/
private $charge;
/**
* @ORM\Column(type="float")
*/
private $heure_par_jour;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $liste_date_pointage = [];
/**
* @ORM\Column(type="datetime")
*/
private $date_crea;
/**
* @ORM\Column(type="integer")
*/
private $user_crea;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $date_modif;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $user_modif;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $id_signature_elec;
/**
* @ORM\Column(type="integer")
*/
private $id_statut_signature_elec;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="integer")
*/
private $mois;
/**
* @ORM\Column(type="integer")
*/
private $annee;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $id_projet;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $date_urssaf;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $statut_urssaf;
private $_error = [];
public function getId(): ?int
{
return $this->id;
}
public function getSalarie(): ?Tiers
{
return $this->salarie;
}
public function setSalarie(?Tiers $salarie): self
{
$this->salarie = $salarie;
return $this;
}
public function getNbJourPointage(): ?int
{
return $this->nb_jour_pointage;
}
public function setNbJourPointage(int $nb_jour_pointage): self
{
$this->nb_jour_pointage = $nb_jour_pointage;
return $this;
}
public function getTarifJour(): ?float
{
return $this->tarif_jour;
}
public function setTarifJour(float $tarif_jour): self
{
$this->tarif_jour = $tarif_jour;
return $this;
}
public function getCharge(): ?float
{
return $this->charge;
}
public function setCharge(float $charge): self
{
$this->charge = $charge;
return $this;
}
public function getHeureParJour(): ?float
{
return $this->heure_par_jour;
}
public function setHeureParJour(float $heure_par_jour): self
{
$this->heure_par_jour = $heure_par_jour;
return $this;
}
public function getListeDatePointage(): ?array
{
return $this->liste_date_pointage;
}
public function setListeDatePointage(?array $liste_date_pointage): self
{
$this->liste_date_pointage = $liste_date_pointage;
return $this;
}
public function getDateCrea(): ?\DateTimeInterface
{
return $this->date_crea;
}
public function setDateCrea(\DateTimeInterface $date_crea): self
{
$this->date_crea = $date_crea;
return $this;
}
public function getUserCrea(): ?int
{
return $this->user_crea;
}
public function setUserCrea(int $user_crea): self
{
$this->user_crea = $user_crea;
return $this;
}
public function getDateModif(): ?\DateTimeInterface
{
return $this->date_modif;
}
public function setDateModif(?\DateTimeInterface $date_modif): self
{
$this->date_modif = $date_modif;
return $this;
}
public function getUserModif(): ?int
{
return $this->user_modif;
}
public function setUserModif(?int $user_modif): self
{
$this->user_modif = $user_modif;
return $this;
}
public function getIdSignatureElec(): ?string
{
return $this->id_signature_elec;
}
public function setIdSignatureElec(?string $id_signature_elec): self
{
$this->id_signature_elec = $id_signature_elec;
return $this;
}
public function getIdStatutSignatureElec(): ?int
{
return $this->id_statut_signature_elec;
}
public function setIdStatutSignatureElec(int $id_statut_signature_elec): self
{
$this->id_statut_signature_elec = $id_statut_signature_elec;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getMois(): ?int
{
return $this->mois;
}
public function setMois(int $mois): self
{
$this->mois = $mois;
return $this;
}
public function getAnnee(): ?int
{
return $this->annee;
}
public function setAnnee(int $annee): self
{
$this->annee = $annee;
return $this;
}
public function getIdProjet(): ?int
{
return $this->id_projet;
}
public function setIdProjet(?int $id_projet): self
{
$this->id_projet = $id_projet;
return $this;
}
public function getDateUrssaf(): ?\DateTimeInterface
{
return $this->date_urssaf;
}
public function setDateUrssaf(?\DateTimeInterface $date_urssaf): self
{
$this->date_urssaf = $date_urssaf;
return $this;
}
public function getStatutUrssaf(): ?string
{
return $this->statut_urssaf;
}
public function setStatutUrssaf(?string $statut_urssaf): self
{
$this->statut_urssaf = $statut_urssaf;
return $this;
}
public function getFirstDate(): ?\DateTime
{
$ldp = $this->getListeDatePointage();
if(empty($ldp)) return null;
return new \DateTime(date('Y-m-d', array_shift($ldp)));
}
public function getLastDate(): ?\DateTime
{
$ldp = $this->getListeDatePointage();
if(empty($ldp)) return null;
return new \DateTime(date('Y-m-d', array_pop($ldp)));
}
public function getDetailsDate()
{
$dateListe = [];
$ldp = $this->getListeDatePointage();
if(!empty($ldp)) foreach ($ldp as $pointage) $dateListe[] = new \DateTime(date('Y-m-d', $pointage));
return $dateListe;
}
public function checkData(string $webPath)
{
$salarie = $this->getSalarie();
if(null===$salarie) $this->_error[] = 'Aucun salarié rattaché au contrat';
$info = $salarie->getInfoSalarie()->initEncryptionKey($webPath)->decryptContent();
if(null===$info) $this->_error[] = 'Aucune infos rattachées au salarié';
if(empty($salarie->getPrenomTiers())) $this->_error[] = 'Prénom salarié vide';
if(empty($salarie->getNomTiers())) $this->_error[] = 'Nom salarié vide';
if(15!==strlen($info->getNumSecuSociale())) $this->_error[] = 'Numéro de sécurité sociale invalide : 15 chiffres attendus';
if(10!==strlen($info->getDateNaissance())) $this->_error[] = 'Date de naissance invalide';
if(empty($info->getLieuNaissance())) $this->_error[] = 'Lieu de naissance vide';
if(preg_match('/[()]/', $info->getLieuNaissance())) $this->_error[] = 'Les parenthèses sont interdites : '. $info->getLieuNaissance();
if(empty($this->getListeDatePointage())) $this->_error[] = 'Aucune date de contrat';
return $this;
}
public function getError()
{
return $this->_error;
}
}