src/Entity/Commande.php line 16

Open in your IDE?
  1. <?php
  2. /**
  3.  * Commande.php
  4.  * Created by Stéphane Brun
  5.  * Date: 03/07/2018 at 15:20
  6.  */
  7. namespace App\Entity;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\CommandeRepository")
  12.  * @ORM\Table(name="commande")
  13.  */
  14. class Commande
  15. {
  16.     const HISTORY_WATCH = array(
  17.         'livraison' => 'Livraison',
  18.         'message' => 'Message',
  19.         'date' => 'Date',
  20.     );
  21.     const TYPE_REASSORT 1;
  22.     const TYPE_PROMO_IN_PLACE 2;
  23.     const TYPE_AGREEMENT_SPECIAL 3;
  24.     const TYPE_OFFICE 4;
  25.     const TYPE_ADD_OFFICE 5;
  26.     const TYPE_DEPOSIT_CONS_COURT 6;
  27.     const TYPE_DEPOSIT_CONS_LONG 7;
  28.     /**
  29.      * @ORM\Column(type="integer")
  30.      * @ORM\Id
  31.      * @ORM\GeneratedValue(strategy="AUTO")
  32.      */
  33.     protected $id;
  34.     /**
  35.      * @ORM\Column(name="date", type="datetime")
  36.      */
  37.     protected $date;
  38.     /**
  39.      * @ORM\Column(name="imprimee", type="boolean")
  40.      */
  41.     protected $imprimee false;
  42.     /**
  43.      * @ORM\Column(name="fermee", type="boolean")
  44.      */
  45.     protected $fermee false;
  46.     /**
  47.      * @ORM\Column(name="recue", type="boolean")
  48.      */
  49.     protected $recue false;
  50.     /**
  51.      * @ORM\Column(name="date_recue", type="datetime", nullable=true)
  52.      */
  53.     protected $dateRecue;
  54.     /**
  55.      * @ORM\Column(name="date_transmise", type="datetime", nullable=true)
  56.      */
  57.     protected $dateTransmise;
  58.     /**
  59.      * @ORM\Column(name="date_confirme", type="datetime", nullable=true)
  60.      */
  61.     protected $dateConfirme;
  62.     /**
  63.      * @ORM\Column(name="accepte_pas_subst", type="boolean")
  64.      */
  65.     protected $acceptePasSubst false;
  66.     /**
  67.      * @ORM\Column(name="message", type="string", length=150, nullable=true)
  68.      */
  69.     protected $message;
  70.     /**
  71.      * has one CommandeType
  72.      *
  73.      * @ORM\ManyToOne(targetEntity="App\Entity\CommandeType")
  74.      * @ORM\JoinColumn(name="type_id", referencedColumnName="id", nullable=true)
  75.      */
  76.     protected $type;
  77.     /**
  78.      * has one Fournisseurs
  79.      *
  80.      * @ORM\ManyToOne(targetEntity="App\Entity\Fournisseurs", inversedBy="commandes")
  81.      * @ORM\JoinColumn(name="fournisseur_id", referencedColumnName="id", nullable=true)
  82.      */
  83.     protected $fournisseur;
  84.     /**
  85.      * has one CommandeLivraison
  86.      *
  87.      * @ORM\ManyToOne(targetEntity="App\Entity\Fournisseurs")
  88.      * @ORM\JoinColumn(name="livraison_id", referencedColumnName="id", nullable=true)
  89.      */
  90.     protected $livraison;
  91.     /**
  92.      * has many CommandeDetail
  93.      *
  94.      * @ORM\OneToMany(targetEntity="CommandeDetail", mappedBy="commande", cascade={"persist", "remove"}, orphanRemoval=true)
  95.      */
  96.     protected $details;
  97.     /**
  98.      * has one Company
  99.      *
  100.      * @ORM\ManyToOne(targetEntity="App\Entity\Company")
  101.      * @ORM\JoinColumn(name="company_id", referencedColumnName="id")
  102.      */
  103.     protected $company;
  104.     /**
  105.      * has one SysUser
  106.      *
  107.      * @ORM\ManyToOne(targetEntity="App\Entity\SysUsers")
  108.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
  109.      */
  110.     protected $user;
  111.     /**
  112.      * @ORM\Column(name="promo_code", type="string", length=150, nullable=true)
  113.      */
  114.     protected $promotionalCode;
  115.     /**
  116.      * @ORM\Column(name="terms", type="string", length=150, nullable=true)
  117.      */
  118.     protected $terms;
  119.     /**
  120.      * @ORM\Column(name="date_return", type="datetime", nullable=true)
  121.      */
  122.     protected $dateReturn;
  123.     /**
  124.      * @ORM\Column(name="date_delivery", type="datetime", nullable=true)
  125.      */
  126.     protected $dateDelivery;
  127.     /**
  128.      * @ORM\Column(name="noted_until", type="datetime", nullable=true)
  129.      */
  130.     protected $notedUntil;
  131.     /**
  132.      * One Product has Many Features.
  133.      * @ORM\OneToMany(targetEntity="Reception", mappedBy="commandeVisee")
  134.      */
  135.     protected $receptions;
  136.     public function __construct()
  137.     {
  138.         $this->details = new ArrayCollection();
  139.         $this->date = new \DateTime();
  140.     }
  141.     public function __toString()
  142.     {
  143.         return (string)$this->getId();
  144.     }
  145.     /**
  146.      * @return mixed
  147.      */
  148.     public function getId()
  149.     {
  150.         return $this->id;
  151.     }
  152.     /**
  153.      * @return mixed
  154.      */
  155.     public function getDate()
  156.     {
  157.         return $this->date;
  158.     }
  159.     /**
  160.      * @param mixed $date
  161.      * @return Commande
  162.      */
  163.     public function setDate($date)
  164.     {
  165.         $this->date $date;
  166.         return $this;
  167.     }
  168.     /**
  169.      * @return mixed
  170.      */
  171.     public function getImprimee()
  172.     {
  173.         return $this->imprimee;
  174.     }
  175.     /**
  176.      * @param mixed $imprimee
  177.      * @return Commande
  178.      */
  179.     public function setImprimee($imprimee)
  180.     {
  181.         $this->imprimee $imprimee;
  182.         return $this;
  183.     }
  184.     /**
  185.      * @return mixed
  186.      */
  187.     public function getFermee()
  188.     {
  189.         return $this->fermee;
  190.     }
  191.     /**
  192.      * @param mixed $fermee
  193.      * @return Commande
  194.      */
  195.     public function setFermee($fermee)
  196.     {
  197.         $this->fermee $fermee;
  198.         return $this;
  199.     }
  200.     /**
  201.      * @return mixed
  202.      */
  203.     public function getRecue()
  204.     {
  205.         return $this->recue;
  206.     }
  207.     /**
  208.      * @param mixed $recue
  209.      * @return Commande
  210.      */
  211.     public function setRecue($recue)
  212.     {
  213.         $this->recue $recue;
  214.         return $this;
  215.     }
  216.     /**
  217.      * @return mixed
  218.      */
  219.     public function getDateRecue()
  220.     {
  221.         return $this->dateRecue;
  222.     }
  223.     /**
  224.      * @param mixed $dateRecue
  225.      * @return Commande
  226.      */
  227.     public function setDateRecue($dateRecue)
  228.     {
  229.         $this->dateRecue $dateRecue;
  230.         return $this;
  231.     }
  232.     /**
  233.      * @return mixed
  234.      */
  235.     public function getDateTransmise()
  236.     {
  237.         return $this->dateTransmise;
  238.     }
  239.     /**
  240.      * @param mixed $dateTransmise
  241.      * @return Commande
  242.      */
  243.     public function setDateTransmise($dateTransmise)
  244.     {
  245.         $this->dateTransmise $dateTransmise;
  246.         return $this;
  247.     }
  248.     /**
  249.      * @return mixed
  250.      */
  251.     public function getDateConfirme()
  252.     {
  253.         return $this->dateConfirme;
  254.     }
  255.     /**
  256.      * @param mixed $dateConfirme
  257.      * @return Commande
  258.      */
  259.     public function setDateConfirme($dateConfirme)
  260.     {
  261.         $this->dateConfirme $dateConfirme;
  262.         return $this;
  263.     }
  264.     /**
  265.      * @return mixed
  266.      */
  267.     public function getAcceptePasSubst()
  268.     {
  269.         return $this->acceptePasSubst;
  270.     }
  271.     /**
  272.      * @param mixed $acceptePasSubst
  273.      * @return Commande
  274.      */
  275.     public function setAcceptePasSubst($acceptePasSubst)
  276.     {
  277.         $this->acceptePasSubst $acceptePasSubst;
  278.         return $this;
  279.     }
  280.     /**
  281.      * @return mixed
  282.      */
  283.     public function getMessage()
  284.     {
  285.         return $this->message;
  286.     }
  287.     /**
  288.      * @param mixed $message
  289.      * @return Commande
  290.      */
  291.     public function setMessage($message)
  292.     {
  293.         $this->message $message;
  294.         return $this;
  295.     }
  296.     /**
  297.      * @return CommandeType
  298.      */
  299.     public function getType()
  300.     {
  301.         return $this->type;
  302.     }
  303.     /**
  304.      * @param CommandeType $type
  305.      * @return Commande
  306.      */
  307.     public function setType(CommandeType $type)
  308.     {
  309.         $this->type $type;
  310.         return $this;
  311.     }
  312.     /**
  313.      * @return mixed
  314.      */
  315.     public function getFournisseur()
  316.     {
  317.         return $this->fournisseur;
  318.     }
  319.     /**
  320.      * @param mixed $fournisseur
  321.      * @return Commande
  322.      */
  323.     public function setFournisseur($fournisseur)
  324.     {
  325.         $this->fournisseur $fournisseur;
  326.         return $this;
  327.     }
  328.     /**
  329.      * @return Fournisseurs
  330.      */
  331.     public function getLivraison()
  332.     {
  333.         return $this->livraison;
  334.     }
  335.     /**
  336.      * @param Fournisseurs $livraison
  337.      * @return Commande
  338.      */
  339.     public function setLivraison(Fournisseurs $livraison)
  340.     {
  341.         $this->livraison $livraison;
  342.         return $this;
  343.     }
  344.     /**
  345.      * @return mixed
  346.      */
  347.     public function getDetails()
  348.     {
  349.         return $this->details;
  350.     }
  351.     /**
  352.      * @param mixed $details
  353.      * @return Commande
  354.      */
  355.     public function setDetails($details)
  356.     {
  357.         $this->details $details;
  358.         return $this;
  359.     }
  360.     /**
  361.      * @param CommandeDetail $detail
  362.      * @return Commande
  363.      */
  364.     public function addDetail(CommandeDetail $detail)
  365.     {
  366.         if (!$this->details->contains($detail)) {
  367.             $this->details->add($detail);
  368.             $detail->setCommande($this);
  369.         }
  370.         return $this;
  371.     }
  372.     /**
  373.      * @param CommandeDetail $detail
  374.      * @return Commande
  375.      */
  376.     public function removeDetail(CommandeDetail $detail)
  377.     {
  378.         if ($this->details->contains($detail)) {
  379.             $this->details->removeElement($detail);
  380.             $detail->setCommande(null);
  381.         }
  382.         return $this;
  383.     }
  384.     /**
  385.      * @return mixed
  386.      */
  387.     public function getCompany()
  388.     {
  389.         return $this->company;
  390.     }
  391.     /**
  392.      * @param mixed $company
  393.      * @return Commande
  394.      */
  395.     public function setCompany($company)
  396.     {
  397.         $this->company $company;
  398.         return $this;
  399.     }
  400.     /**
  401.      * @return SysUsers
  402.      */
  403.     public function getUser()
  404.     {
  405.         return $this->user;
  406.     }
  407.     /**
  408.      * @param SysUsers $user
  409.      * @return Commande
  410.      */
  411.     public function setUser(SysUsers $user)
  412.     {
  413.         $this->user $user;
  414.         return $this;
  415.     }
  416.     /**
  417.      * @return string
  418.      */
  419.     public function getPromotionalCode()
  420.     {
  421.         return $this->promotionalCode;
  422.     }
  423.     /**
  424.      * @param string $promotionalCode
  425.      */
  426.     public function setPromotionalCode($promotionalCode)
  427.     {
  428.         $this->promotionalCode $promotionalCode;
  429.     }
  430.     /**
  431.      * @return string
  432.      */
  433.     public function getTerms()
  434.     {
  435.         return $this->terms;
  436.     }
  437.     /**
  438.      * @param string $terms
  439.      */
  440.     public function setTerms($terms)
  441.     {
  442.         $this->terms $terms;
  443.     }
  444.     /**
  445.      * @return \DateTime|null
  446.      */
  447.     public function getDateReturn()
  448.     {
  449.         return $this->dateReturn;
  450.     }
  451.     /**
  452.      * @param \DateTime|null $dateReturn
  453.      */
  454.     public function setDateReturn($dateReturn)
  455.     {
  456.         $this->dateReturn $dateReturn;
  457.     }
  458.     /**
  459.      * @return \DateTime|null
  460.      */
  461.     public function getDateDelivery()
  462.     {
  463.         return $this->dateDelivery;
  464.     }
  465.     /**
  466.      * @param \DateTime|null $dateDelivery
  467.      */
  468.     public function setDateDelivery($dateDelivery)
  469.     {
  470.         $this->dateDelivery $dateDelivery;
  471.     }
  472.     /**
  473.      * @return \DateTime|null
  474.      */
  475.     public function getNotedUntil()
  476.     {
  477.         return $this->notedUntil;
  478.     }
  479.     /**
  480.      * @param \DateTime|null $notedUntil
  481.      */
  482.     public function setNotedUntil($notedUntil)
  483.     {
  484.         $this->notedUntil $notedUntil;
  485.     }
  486.     /**
  487.      * @return bool
  488.      */
  489.     public function isTransmit()
  490.     {
  491.         if (!empty($this->getDateTransmise()) || true === $this->getImprimee()) {
  492.             return true;
  493.         }
  494.         return false;
  495.     }
  496.     /**
  497.      * @return mixed
  498.      */
  499.     public function getReceptions()
  500.     {
  501.         return $this->receptions;
  502.     }
  503.     /**
  504.      * @param mixed $receptions
  505.      */
  506.     public function setReceptions($receptions): void
  507.     {
  508.         $this->receptions $receptions;
  509.     }
  510. }