src/App/Entity/CubageLivraison.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CubageLivraisonRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Blameable\Traits\BlameableEntity;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. use GollumSF\EntityRelationSetter\ManyToOneSetter;
  9. use GollumSF\EntityRelationSetter\OneToManySetter;
  10. use GollumSF\RestBundle\Serializer\Transform\UnserializerTransformInterface;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14.  * @ORM\Table()
  15.  * @ORM\Entity(repositoryClass=CubageLivraisonRepository::class)
  16.  */
  17. class CubageLivraison implements UnserializerTransformInterface {
  18.     
  19.     use BlameableEntity;
  20.     use TimestampableEntity;
  21.     use ManyToOneSetter;
  22.     use OneToManySetter;
  23.     
  24.     /**
  25.      * @ORM\Column(type="integer", length=25, options={"unsigned"=true})
  26.      * @ORM\Id
  27.      * @ORM\GeneratedValue(strategy="AUTO")
  28.      * @Groups({
  29.      *     "cubageLivraison_get", "cubageLivraison_getc",
  30.      *     "cubageLivraisonPlateforme_get", "cubageLivraisonPlateforme_getc",
  31.      *  "get", "getC",
  32.      *     "chantier_get", 
  33.      * "livraison_get",
  34.      * })
  35.      *
  36.      * @var int
  37.      */
  38.     private $id;
  39.     /**
  40.      * @ORM\Column(type="datetime")
  41.      * @Groups({
  42.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  43.      * "livraison_post", "livraison_put",
  44.      *     "plateforme_get", "plateforme_getc",
  45.      *     "cubageLivraisonPlateforme_get", "cubageLivraisonPlateforme_getc",
  46.      * })
  47.      *
  48.      * @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
  49.      *
  50.      * @var \DateTime
  51.      */
  52.     private $date;
  53.     
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity=Chauffeur::class, inversedBy="cubageLivraisons", fetch="EAGER")
  56.      * @Groups({
  57.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  58.      * "livraison_post", "livraison_put",
  59.      *     "plateforme_get", "plateforme_getc",
  60.      *     "cubageLivraisonPlateforme_get", "cubageLivraisonPlateforme_getc",
  61.      * })
  62.      *
  63.      * @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
  64.      *
  65.      * @var string
  66.      */
  67.     private $chauffeur;
  68.     /**
  69.      * @ORM\Column(type="string", nullable=true)
  70.      * @Groups({
  71.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  72.      * "livraison_post", "livraison_put",
  73.      *     "plateforme_get", "plateforme_getc",
  74.      *     "cubageLivraisonPlateforme_get", "cubageLivraisonPlateforme_getc",
  75.      * })
  76.      *
  77.      * @Assert\Length(max=255, groups={"cubageLivraison_post", "cubageLivraison_put"})
  78.      *
  79.      * @var string
  80.      */
  81.     private $bl;
  82.         /**
  83.      * @ORM\Column(type="string", nullable=true)
  84.      * @Groups({
  85.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  86.      * "livraison_post", "livraison_put",
  87.      *     "plateforme_get", "plateforme_getc",
  88.      *     "cubageLivraisonPlateforme_get", "cubageLivraisonPlateforme_getc",
  89.      * })
  90.      *
  91.      * @Assert\Length(max=255, groups={"livraison_post", "livraison_put"})
  92.      *
  93.      * @var string
  94.      */
  95.     private $numfacture;
  96.     /**
  97.      * @ORM\ManyToOne(targetEntity=Tiers::class, inversedBy="cubageLivraisons", fetch="EAGER")
  98.      * @Groups({
  99.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  100.      * "livraison_post", "livraison_put",
  101.      * })
  102.      *
  103.      * @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
  104.      *
  105.      * @var Tiers
  106.      */
  107.     private $scierie;
  108.     
  109.     /**
  110.      * @ORM\ManyToOne(targetEntity=Livraison::class, inversedBy="cubageLivraisons")
  111.      * @Groups({
  112.      * "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  113.      * })
  114.      * 
  115.      * @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
  116.      *
  117.      * @var Livraison
  118.      */
  119.     private $livraison;
  120.     /**
  121.      * @ORM\Column(type="boolean")
  122.      * @Groups({
  123.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  124.      * })
  125.      *
  126.      * @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
  127.      *
  128.      * @var bool
  129.      */
  130.     private $estimer false;
  131.     /**
  132.      * @ORM\Column(type="boolean")
  133.      * @Groups({
  134.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  135.      *     "cubageLivraisonPlateforme_get", "cubageLivraisonPlateforme_getc",
  136.      *     "plateforme_get", "plateforme_getc",
  137.      *     "chantier_get", 
  138.      * })
  139.      *
  140.      * @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
  141.      *
  142.      * @var bool
  143.      */
  144.     private $boisFini false// indique qu'il n y a plus de bois de ce type sur chantier
  145.     /**
  146.      * @ORM\ManyToOne(targetEntity=BoisType::class, inversedBy="cubageLivraisons", fetch="EAGER")
  147.      * @Groups({
  148.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  149.      *     "chantier_get", 
  150.      * "livraison_get",
  151.      * })
  152.      *
  153.      * @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
  154.      *
  155.      * @var BoisType
  156.      */
  157.     private $boisType;
  158.     
  159.     /**
  160.      * @ORM\ManyToOne(targetEntity=BoisQuality::class, inversedBy="cubageLivraisons", fetch="EAGER")
  161.      * @Groups({
  162.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  163.      *     "chantier_get", 
  164.      * "livraison_get",
  165.      * })
  166.      *
  167.      * @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
  168.      *
  169.      * @var BoisQuality
  170.      */
  171.     private $boisQuality;
  172.     
  173.     /**
  174.      * @ORM\ManyToOne(targetEntity=BoisSize::class, inversedBy="cubageLivraisons", fetch="EAGER")
  175.      * @Groups({
  176.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  177.      *     "chantier_get", 
  178.      * "livraison_get",
  179.      * })
  180.      *
  181.      * @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
  182.      *
  183.      * @var BoisSize
  184.      */
  185.     private $boisSize;
  186.     
  187.     /**
  188.      * @ORM\ManyToOne(targetEntity=Marquage::class, inversedBy="cubageLivraisons")
  189.      * @Groups({
  190.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  191.      *     "chantier_get", 
  192.      * "livraison_get",
  193.      * })
  194.      *
  195.      * @var Marquage
  196.      */
  197.     private $marquage;
  198.     /**
  199.      * @ORM\Column(type="float")
  200.      * @Groups({
  201.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  202.      *     "cubageLivraisonPlateforme_get", "cubageLivraisonPlateforme_getc",
  203.      *     "chantier_get", 
  204.      * "livraison_get",
  205.      * })
  206.      *
  207.      * @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
  208.      *
  209.      * @var float
  210.      */
  211.     private $volumeInner;
  212.     /**
  213.      * @ORM\Column(type="boolean")
  214.      * @Groups({
  215.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  216.      *     "chantier_get", 
  217.      * "livraison_get",
  218.      * })
  219.      *
  220.      * @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
  221.      *
  222.      * @var bool
  223.      */
  224.     private $volumeApproximatif true
  225.     /**
  226.      * @ORM\Column(type="float", nullable=true)
  227.      * @Groups({
  228.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put"
  229.      * })
  230.      *
  231.      * @var float
  232.      */
  233.     private $volumeOutter;
  234.     /**
  235.      * @ORM\Column(type="float", nullable=true)
  236.      * @Groups({
  237.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put"
  238.      * })
  239.      *
  240.      * @var float
  241.      */
  242.     private $coef;
  243.     
  244.     /**
  245.      * @ORM\Column(type="float", nullable=true)
  246.      * @Groups({
  247.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put"
  248.      * })
  249.      *
  250.      * @var float
  251.      */
  252.     private $volumeStere;
  253.     /**
  254.      * @ORM\Column(type="float", nullable=true)
  255.      * @Groups({
  256.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put"
  257.      * })
  258.      *
  259.      * @var float
  260.      */
  261.     private $coefStere;
  262.     
  263.     /**
  264.      * @ORM\Column(type="float", nullable=true)
  265.      * @Groups({
  266.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put"
  267.      * })
  268.      *
  269.      * @var float
  270.      */
  271.     private $volumeTonne;
  272.     /**
  273.      * @ORM\Column(type="float", nullable=true)
  274.      * @Groups({
  275.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put"
  276.      * })
  277.      *
  278.      * @var float
  279.      */
  280.     private $coefTonne;
  281.     
  282.     /**
  283.      * @ORM\Column(type="float", nullable=true)
  284.      * @Groups({
  285.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  286.      * "livraison_get",
  287.      * })
  288.      *
  289.      * @var float
  290.      */
  291.     private $prixM3;
  292.     /**
  293.      * @ORM\Column(type="float", nullable=true)
  294.      * @Groups({
  295.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  296.      * "livraison_get",
  297.      * })
  298.      *
  299.      * @var float
  300.      */
  301.     private $prixStere;
  302.     /**
  303.      * @ORM\Column(type="float", nullable=true)
  304.      * @Groups({
  305.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  306.      * "livraison_get",
  307.      * })
  308.      *
  309.      * @var float
  310.      */
  311.     private $prixTonne;
  312.     /**
  313.      * @ORM\Column(type="float", nullable=true)
  314.      * @Groups({
  315.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  316.      * "livraison_get",
  317.      * })
  318.      *
  319.      * @var float
  320.      */
  321.     private $prixCamion;
  322.     /**
  323.      * @ORM\ManyToOne(targetEntity=Chantier::class, inversedBy="cubageLivraisons", fetch="EAGER")
  324.      * @Groups({
  325.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post",
  326.      *     "plateforme_get", "plateforme_getc",
  327.      *     "cubageLivraisonPlateforme_get", "cubageLivraisonPlateforme_getc",
  328.      * "livraison_get",
  329.      * })
  330.      *
  331.      * @Assert\NotNull(groups={"cubageLivraison_post", "cubageLivraison_put"})
  332.      *
  333.      * @var Chantier
  334.      */
  335.     private $chantier;
  336.     
  337.     /**
  338.      * @ORM\OneToMany(targetEntity=DocumentCubageLivraison::class, mappedBy="cubageLivraison", cascade={"remove"})
  339.      * @Groups({
  340.      *     "cubageLivraison_get", "cubageLivraison_getc",
  341.      * })
  342.      *
  343.      * @var DocumentCubageLivraison[]|ArrayCollection
  344.      */
  345.     private $documentCubageLivraisons;
  346.     /**
  347.      * @ORM\ManyToOne(targetEntity=CubageLivraisonPlateforme::class, inversedBy="cubageLivraisons", fetch="EAGER")
  348.      * @Groups({
  349.      *     "cubageLivraison_get", "cubageLivraison_getc", "cubageLivraison_post", "cubageLivraison_put",
  350.      *     "chantier_get",
  351.      * })
  352.      *
  353.      * @var CubageLivraisonPlateforme
  354.      */
  355.     private $cubageLivraisonPlateforme;
  356.     
  357.     public function __construct() {
  358.         $this->documentCubageLivraisons = new ArrayCollection();
  359.     }
  360.     /////////////
  361.     // Getters //
  362.     /////////////
  363.     
  364.     public function getId(): ?int {
  365.         return $this->id;
  366.     }
  367.     public function getDate(): ?\DateTime {
  368.         return $this->date;
  369.     }
  370.     
  371.     public function getChauffeur(): ?Chauffeur {
  372.         return $this->chauffeur;
  373.     }
  374.     public function getBl(): ?string {
  375.         return $this->bl;
  376.     }
  377.     public function getNumfacture(): ?string {
  378.         return $this->numfacture;
  379.     }
  380.     public function getScierie(): ?Tiers {
  381.         return $this->scierie;
  382.     }
  383.     
  384.     public function getLivraison(): ?Livraison {
  385.         return $this->livraison;
  386.     }
  387.     
  388.     public function getEstimer(): ?bool {
  389.         return $this->estimer;
  390.     }
  391.     
  392.     public function getBoisFini(): ?bool {
  393.         return $this->boisFini;
  394.     }
  395.     
  396.     public function getVolumeApproximatif(): ?bool {
  397.         return $this->volumeApproximatif;
  398.     }
  399.     public function getBoisType(): ?BoisType {
  400.         return $this->boisType;
  401.     }
  402.     
  403.     public function getBoisQuality(): ?BoisQuality {
  404.         return $this->boisQuality;
  405.     }
  406.     
  407.     public function getBoisSize(): ?BoisSize {
  408.         return $this->boisSize;
  409.     }
  410.     
  411.     public function getMarquage(): ?Marquage {
  412.         return $this->marquage;
  413.     }
  414.     public function getVolumeInner(): ?float {
  415.         return $this->volumeInner;
  416.     }
  417.     public function getVolumeOutter(): ?float {
  418.         return $this->volumeOutter;
  419.     }
  420.     public function getCoef(): ?float {
  421.         return $this->coef;
  422.     }
  423.     
  424.     public function getVolumeStere(): ?float {
  425.         return $this->volumeStere;
  426.     }
  427.     public function getCoefStere(): ?float {
  428.         return $this->coefStere;
  429.     }
  430.     
  431.     public function getVolumeTonne(): ?float {
  432.         return $this->volumeTonne;
  433.     }
  434.     public function getCoefTonne(): ?float {
  435.         return $this->coefTonne;
  436.     }
  437.     
  438.     public function getPrixM3(): ?float {
  439.         return $this->prixM3;
  440.     }
  441.     
  442.     public function getPrixStere(): ?float {
  443.         return $this->prixStere;
  444.     }
  445.     
  446.     public function getPrixTonne(): ?float {
  447.         return $this->prixTonne;
  448.     }
  449.     
  450.     public function getPrixCamion(): ?float {
  451.         return $this->prixCamion;
  452.     }
  453.     
  454.     public function getChantier(): ?Chantier {
  455.         return $this->chantier;
  456.     }
  457.     
  458.     /**
  459.      * @return DocumentCubageLivraison[]|ArrayCollection
  460.      */
  461.     public function getDocumentCubageLivraisons() {
  462.         return $this->documentCubageLivraisons;
  463.     }
  464.     public function getCubageLivraisonPlateforme(): ?CubageLivraisonPlateforme {
  465.         return $this->cubageLivraisonPlateforme;
  466.     }
  467.     
  468.     /////////////
  469.     // Setters //
  470.     /////////////
  471.     public function setDate(?\DateTime $date): self {
  472.         $this->date $date;
  473.         return $this;
  474.     }
  475.     
  476.     public function setChauffeur(?Chauffeur $chauffeur): self {
  477.         return $this->manyToOneSet($chauffeur);
  478.     }
  479.     public function setBl(?string $bl): self {
  480.         $this->bl $bl;
  481.         return $this;
  482.     }
  483.     public function setNumfacture(?string $bl): self {
  484.         $this->numfacture $bl;
  485.         return $this;
  486.     }
  487.     public function setScierie(?Tiers $scierie): self {
  488.         return $this->manyToOneSet($scierie'scierie''cubageLivraison');
  489.     }
  490.     public function setLivraison(?Livraison $value): self {
  491.         return $this->manyToOneSet($value);
  492.     }
  493.     
  494.     public function setEstimer(?bool $estimer): self {
  495.         $this->estimer $estimer;
  496.         return $this;
  497.     }
  498.     
  499.     public function setBoisFini(?bool $boisFini): self {
  500.         $this->boisFini $boisFini;
  501.         return $this;
  502.     }
  503.         
  504.     public function setVolumeApproximatif(?bool $volumeApproximatif): self {
  505.         $this->volumeApproximatif $volumeApproximatif;
  506.         return $this;
  507.     }
  508.     public function setBoisType(?BoisType $boisType): self {
  509.         return $this->manyToOneSet($boisType);
  510.     }
  511.     
  512.     public function setBoisQuality(?BoisQuality $boisQuality): self {
  513.         return $this->manyToOneSet($boisQuality);
  514.     }
  515.     
  516.     public function setBoisSize(?BoisSize $boisSize): self {
  517.         return $this->manyToOneSet($boisSize);
  518.     }
  519.     
  520.     public function setMarquage(?Marquage $marquage): self {
  521.         return $this->manyToOneSet($marquage);
  522.     }
  523.     public function setVolumeInner(?float $volumeInner): self {
  524.         $this->volumeInner $volumeInner;
  525.         return $this;
  526.     }
  527.     public function setVolumeOutter(?float $volumeOutter): self {
  528.         $this->volumeOutter $volumeOutter;
  529.         return $this;
  530.     }
  531.     public function setCoef(?float $coef): self {
  532.         $this->coef $coef;
  533.         return $this;
  534.     }
  535.     
  536.     public function setVolumeStere(?float $volumeStere): self {
  537.         $this->volumeStere $volumeStere;
  538.         return $this;
  539.     }
  540.     public function setCoefStere(?float $coef): self {
  541.         $this->coefStere $coef;
  542.         return $this;
  543.     }
  544.     
  545.     public function setVolumeTonne(?float $volumeStere): self {
  546.         $this->volumeTonne $volumeStere;
  547.         return $this;
  548.     }
  549.     public function setCoefTonne(?float $coef): self {
  550.         $this->coefTonne $coef;
  551.         return $this;
  552.     }
  553.     
  554.     public function setPrixM3(?float $prixM3): self {
  555.         $this->prixM3 $prixM3;
  556.         return $this;
  557.     }
  558.     public function setPrixStere(?float $prixStere): self {
  559.         $this->prixStere $prixStere;
  560.         return $this;
  561.     }
  562.     
  563.     public function setPrixTonne(?float $prixTonne): self {
  564.         $this->prixTonne $prixTonne;
  565.         return $this;
  566.     }
  567.     
  568.     public function setPrixCamion(?float $prixCamion): self {
  569.         $this->prixCamion $prixCamion;
  570.         return $this;
  571.     }
  572.     
  573.     public function setChantier(?Chantier $chantier): self {
  574.         return $this->manyToOneSet($chantier);
  575.     }
  576.     public function setCubageLivraisonPlateforme (?CubageLivraisonPlateforme $cubageLivraisonPlateforme): self {
  577.         return $this->manyToOneSet($cubageLivraisonPlateforme);
  578.     }
  579.     
  580.     /////////
  581.     // Add //
  582.     /////////
  583.     
  584.     public function addDocumentCubageLivraison(DocumentCubageLivraison $document): self {
  585.         return $this->oneToManyAdd($document);
  586.     }
  587.     ////////////
  588.     // Remove //
  589.     ////////////
  590.     
  591.     public function removeDocumentCubageLivraison(DocumentCubageLivraison $document): self {
  592.         return $this->oneToManyRemove($document);
  593.     }
  594.     
  595.     ///////////////
  596.     // Serialize //
  597.     ///////////////
  598.     
  599.     /**
  600.      * @param $data
  601.      * @param string[] $groups
  602.      */
  603.     public function unserializeTransform($data, array $groups): void {
  604.         if ($this->volumeOutter && $this->coef) {
  605.             $this->volumeInner round($this->volumeOutter $this->coef2);
  606.         } else
  607.         if ($this->volumeInner && $this->coef) {
  608.             $this->volumeOutter round($this->volumeInner $this->coef2);
  609.         } else
  610.         if ($this->volumeInner && $this->volumeOutter) {
  611.             $this->coef round($this->volumeInner $this->volumeOutter2);
  612.         }
  613.     }
  614. }