src/Entity/CommandeSpeciale.php line 16

Open in your IDE?
  1. <?php
  2. /**
  3.  * CommandeSpeciale.php
  4.  * Created by Stéphane Brun
  5.  * Date: 08/06/2018 at 10:26
  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\CommandeSpecialeRepository")
  12.  * @ORM\Table(name="commande_speciale")
  13.  */
  14. class CommandeSpeciale
  15. {
  16.     const HISTORY_WATCH = array(
  17.         'telephone' => 'Telephone',
  18.         'client' => 'Client',
  19.         'bonCommande' => 'Bon de commande',
  20.         'clientAdl' => 'Adresse de livraison',
  21.         'commentaire' => 'Commentaire',
  22.     );
  23.     /**
  24.      * @ORM\Column(type="integer")
  25.      * @ORM\Id
  26.      * @ORM\GeneratedValue(strategy="AUTO")
  27.      */
  28.     protected $id;
  29.     /**
  30.      * @ORM\Column(name="telephone", type="string", length=50, nullable=true)
  31.      */
  32.     protected $telephone;
  33.     /**
  34.      * @ORM\Column(name="date_demande", type="datetime")
  35.      */
  36.     protected $dateDemande;
  37.     /**
  38.      * @ORM\Column(name="date_limite", type="datetime", nullable=true)
  39.      */
  40.     protected $dateLimite;
  41.     /**
  42.      * @ORM\Column(name="numero", type="string", length=50, nullable=true)
  43.      */
  44.     protected $numero;
  45.     
  46.     /**
  47.      * @ORM\Column(name="acompte_recu", type="boolean")
  48.      */
  49.     protected $acompteRecu false;
  50.     /**
  51.      * @ORM\Column(name="commentaire", type="text", nullable=true)
  52.      */
  53.     protected $commentaire;
  54.     /**
  55.      * @ORM\Column(name="bon_commande", type="string", length=100, nullable=true)
  56.      */
  57.     protected $bonCommande;
  58.     /**
  59.      * @ORM\Column(name="commande_en_ligne_courriel ", type="string", length=255, nullable=true)
  60.      */
  61.     protected $commandeEnLigneCourriel;
  62.     /**
  63.      * has one SysUser
  64.      *
  65.      * @ORM\ManyToOne(targetEntity="App\Entity\SysUsers")
  66.      * @ORM\JoinColumn(name="user_id", referencedColumnName="id")
  67.      */
  68.     protected $user;
  69.     /**
  70.      * has one Client
  71.      *
  72.      * @ORM\ManyToOne(targetEntity="App\Entity\Clients")
  73.      * @ORM\JoinColumn(name="client_id", referencedColumnName="id")
  74.      */
  75.     protected $client;
  76.     /**
  77.      * has one ClientsAdressesLivraison
  78.      *
  79.      * @ORM\ManyToOne(targetEntity="App\Entity\ClientsAdressesLivraison")
  80.      * @ORM\JoinColumn(name="clientADL_id", referencedColumnName="id", nullable=true)
  81.      */
  82.     protected $clientADL;
  83.     /**
  84.      * has many CommandeSpecialeDetail
  85.      *
  86.      * @ORM\OneToMany(targetEntity="CommandeSpecialeDetail", mappedBy="commandeSpeciale", cascade={"persist", "remove"}, orphanRemoval=true)
  87.      */
  88.     protected $details;
  89.     /**
  90.      * has one Company
  91.      *
  92.      * @ORM\ManyToOne(targetEntity="App\Entity\Company")
  93.      * @ORM\JoinColumn(name="company_id", referencedColumnName="id")
  94.      */
  95.     protected $company;
  96.     /**
  97.      * has one CommandeEnLigneType
  98.      *
  99.      * @ORM\ManyToOne(targetEntity="App\Entity\CommandeEnLigneType")
  100.      * @ORM\JoinColumn(name="commande_en_ligne_type_id", referencedColumnName="id", nullable=true)
  101.      */
  102.     protected $commandeEnLigneType;
  103.     /**
  104.      * @ORM\Column(name="mail_order_receive_count", type="integer", nullable=false)
  105.      */
  106.     protected $mailOrderReceiveCount 0;
  107.     
  108.     /**
  109.      * @ORM\Column(name="date_rembourse", type="datetime", nullable=true)
  110.      */
  111.     protected $dateRembourse;
  112.     
  113.     /**
  114.      * @ORM\Column(name="notes", type="text", nullable=true)
  115.      */
  116.     protected $notes;
  117.     
  118.     /**
  119.      * @ORM\Column(name="comptant", type="float", nullable=true)
  120.      */
  121.     protected $comptant;
  122.     
  123.     /**
  124.      * @ORM\Column(name="mastercard", type="float", nullable=true)
  125.      */
  126.     protected $mastercard;
  127.     
  128.     /**
  129.      * @ORM\Column(name="visa", type="float", nullable=true)
  130.      */
  131.     protected $visa;
  132.     
  133.     /**
  134.      * @ORM\Column(name="interact", type="float", nullable=true)
  135.      */
  136.     protected $interact;
  137.     
  138.     /**
  139.      * @ORM\Column(name="certificat_cadeau", type="float", nullable=true)
  140.      */
  141.     protected $certificatCadeau;
  142.     
  143.     /**
  144.      * @ORM\Column(name="acompte_update", type="boolean")
  145.      */
  146.     protected $acompteUpdate false;
  147.     public function __construct()
  148.     {
  149.         $this->details = new ArrayCollection();
  150.         $this->dateDemande = new \DateTime();
  151.     }
  152.     /**
  153.      * @return mixed
  154.      */
  155.     public function getId()
  156.     {
  157.         return $this->id;
  158.     }
  159.     /**
  160.      * @return mixed
  161.      */
  162.     public function getTelephone()
  163.     {
  164.         return $this->telephone;
  165.     }
  166.     /**
  167.      * @param mixed $telephone
  168.      */
  169.     public function setTelephone($telephone)
  170.     {
  171.         $this->telephone $telephone;
  172.     }
  173.     /**
  174.      * @return mixed
  175.      */
  176.     public function getDateDemande()
  177.     {
  178.         return $this->dateDemande;
  179.     }
  180.     /**
  181.      * @param mixed $dateDemande
  182.      */
  183.     public function setDateDemande(\DateTime $dateDemande)
  184.     {
  185.         $this->dateDemande $dateDemande;
  186.     }
  187.     /**
  188.      * @return mixed
  189.      */
  190.     public function getDateLimite()
  191.     {
  192.         return $this->dateLimite;
  193.     }
  194.     /**
  195.      * @param mixed $dateLimite
  196.      */
  197.     public function setDateLimite(\DateTime $dateLimite)
  198.     {
  199.         $this->dateLimite $dateLimite;
  200.     }
  201.     /**
  202.      * @return mixed
  203.      */
  204.     public function getNumero()
  205.     {
  206.         if ($this->numero){
  207.           return $this->numero;
  208.         } else if ($this->getId()) {
  209.             return "N".$this->getId();
  210.         } else {
  211.             return "NA";
  212.         }
  213.     }
  214.     /**
  215.      * @param mixed $numero
  216.      */
  217.     public function setNumero($numero)
  218.     {
  219.         $this->numero $numero;
  220.     }
  221.     /**
  222.      * @return mixed
  223.      */
  224.     public function getCommentaire()
  225.     {
  226.         return $this->commentaire;
  227.     }
  228.     /**
  229.      * @param mixed $commentaire
  230.      */
  231.     public function setCommentaire($commentaire)
  232.     {
  233.         $this->commentaire $commentaire;
  234.     }
  235.     /**
  236.      * @return mixed
  237.      */
  238.     public function getClient()
  239.     {
  240.         return $this->client;
  241.     }
  242.     /**
  243.      * @param mixed $client
  244.      */
  245.     public function setClient(Clients $client)
  246.     {
  247.         $this->client $client;
  248.     }
  249.     /**
  250.      * @return mixed
  251.      */
  252.     public function getClientADL()
  253.     {
  254.         return $this->clientADL;
  255.     }
  256.     /**
  257.      * @param mixed $clientADL
  258.      */
  259.     public function setClientADL($clientADL=null)
  260.     {
  261.         $this->clientADL $clientADL;
  262.     }
  263.     /**
  264.      * @return mixed
  265.      */
  266.     public function getDetails()
  267.     {
  268.         return $this->details;
  269.     }
  270.     /**
  271.      * @param mixed $details
  272.      */
  273.     public function setDetails($details)
  274.     {
  275.         $this->details $details;
  276.     }
  277.     /**
  278.      * @param CommandeSpecialeDetail $detail
  279.      * @return CommandeSpeciale
  280.      */
  281.     public function addDetail(CommandeSpecialeDetail $detail)
  282.     {
  283.         if (!$this->details->contains($detail)) {
  284.             $this->details->add($detail);
  285.             $detail->setCommandeSpeciale($this);
  286.         }
  287.         return $this;
  288.     }
  289.     /**
  290.      * @param CommandeSpecialeDetail $detail
  291.      * @return CommandeSpeciale
  292.      */
  293.     public function removeDetail(CommandeSpecialeDetail $detail)
  294.     {
  295.         if ($this->details->contains($detail)) {
  296.             $this->details->removeElement($detail);
  297.             $detail->setCommandeSpeciale(null);
  298.         }
  299.         return $this;
  300.     }
  301.     /**
  302.      * @return mixed
  303.      */
  304.     public function getCompany()
  305.     {
  306.         return $this->company;
  307.     }
  308.     /**
  309.      * @param mixed $company
  310.      * @return CommandeSpeciale
  311.      */
  312.     public function setCompany(Company $company)
  313.     {
  314.         $this->company $company;
  315.         return $this;
  316.     }
  317.     /**
  318.      * @return mixed
  319.      */
  320.     public function getUser()
  321.     {
  322.         return $this->user;
  323.     }
  324.     /**
  325.      * @param mixed $user
  326.      * @return CommandeSpeciale
  327.      */
  328.     public function setUser(SysUsers $user)
  329.     {
  330.         $this->user $user;
  331.         return $this;
  332.     }
  333.     /**
  334.      * @return mixed
  335.      */
  336.     public function getBonCommande()
  337.     {
  338.         return $this->bonCommande;
  339.     }
  340.     /**
  341.      * @param mixed $bonCommande
  342.      * @return CommandeSpeciale
  343.      */
  344.     public function setBonCommande($bonCommande)
  345.     {
  346.         $this->bonCommande $bonCommande;
  347.         return $this;
  348.     }
  349.     /**
  350.      * @return mixed
  351.      */
  352.     public function getMailOrderReceiveCount()
  353.     {
  354.         return $this->mailOrderReceiveCount;
  355.     }
  356.     /**
  357.      * @param mixed $mailOrderReceiveCount
  358.      */
  359.     public function setMailOrderReceiveCount($mailOrderReceiveCount)
  360.     {
  361.         $this->mailOrderReceiveCount $mailOrderReceiveCount;
  362.     }
  363.     /**
  364.      * @return mixed
  365.      */
  366.     public function getCommandeEnLigneCourriel()
  367.     {
  368.         return $this->commandeEnLigneCourriel;
  369.     }
  370.     /**
  371.      * @param mixed $commandeEnLigneCourriel
  372.      * @return CommandeSpeciale
  373.      */
  374.     public function setCommandeEnLigneCourriel($commandeEnLigneCourriel)
  375.     {
  376.         $this->commandeEnLigneCourriel $commandeEnLigneCourriel;
  377.         return $this;
  378.     }
  379.     /**
  380.      * @return mixed
  381.      */
  382.     public function getCommandeEnLigneType()
  383.     {
  384.         return $this->commandeEnLigneType;
  385.     }
  386.     /**
  387.      * @param mixed $commandeEnLigneType
  388.      * @return CommandeSpeciale
  389.      */
  390.     public function setCommandeEnLigneType($commandeEnLigneType)
  391.     {
  392.         $this->commandeEnLigneType $commandeEnLigneType;
  393.         return $this;
  394.     }
  395.     
  396.     /**
  397.      * @return mixed
  398.      */
  399.     public function getAcompteRecu()
  400.     {
  401.         return $this->acompteRecu;
  402.     }
  403.     
  404.     /**
  405.      * @param mixed $acompteRecu
  406.      * @return CommandeSpeciale
  407.      */
  408.     public function setAcompteRecu($acompteRecu)
  409.     {
  410.         $this->acompteRecu $acompteRecu;
  411.         return $this;
  412.     }
  413.     
  414.     /**
  415.      * @return mixed
  416.      */
  417.     public function getNotes()
  418.     {
  419.         return $this->notes;
  420.     }
  421.     
  422.     /**
  423.      * @param mixed $notes
  424.      * @return CommandeSpeciale
  425.      */
  426.     public function setNotes($notes)
  427.     {
  428.         $this->notes $notes;
  429.         return $this;
  430.     }
  431.     
  432.     /**
  433.      * @return mixed
  434.      */
  435.     public function getComptant()
  436.     {
  437.         return $this->comptant;
  438.     }
  439.     
  440.     /**
  441.      * @param mixed $comptant
  442.      * @return CommandeSpeciale
  443.      */
  444.     public function setComptant($comptant)
  445.     {
  446.         $this->comptant $comptant;
  447.         return $this;
  448.     }
  449.     
  450.     /**
  451.      * @return mixed
  452.      */
  453.     public function getMastercard()
  454.     {
  455.         return $this->mastercard;
  456.     }
  457.     
  458.     /**
  459.      * @param mixed $mastercard
  460.      * @return CommandeSpeciale
  461.      */
  462.     public function setMastercard($mastercard)
  463.     {
  464.         $this->mastercard $mastercard;
  465.         return $this;
  466.     }
  467.     
  468.     /**
  469.      * @return mixed
  470.      */
  471.     public function getVisa()
  472.     {
  473.         return $this->visa;
  474.     }
  475.     
  476.     /**
  477.      * @param mixed $visa
  478.      * @return CommandeSpeciale
  479.      */
  480.     public function setVisa($visa)
  481.     {
  482.         $this->visa $visa;
  483.         return $this;
  484.     }
  485.     
  486.     /**
  487.      * @return mixed
  488.      */
  489.     public function getInteract()
  490.     {
  491.         return $this->interact;
  492.     }
  493.     
  494.     /**
  495.      * @param mixed $interact
  496.      * @return CommandeSpeciale
  497.      */
  498.     public function setInteract($interact)
  499.     {
  500.         $this->interact $interact;
  501.         return $this;
  502.     }
  503.     
  504.     /**
  505.      * @return mixed
  506.      */
  507.     public function getCertificatCadeau()
  508.     {
  509.         return $this->certificatCadeau;
  510.     }
  511.     
  512.     /**
  513.      * @param mixed $certificatCadeau
  514.      * @return CommandeSpeciale
  515.      */
  516.     public function setCertificatCadeau($certificatCadeau)
  517.     {
  518.         $this->certificatCadeau $certificatCadeau;
  519.         return $this;
  520.     }
  521.     
  522.     /**
  523.      * @return mixed
  524.      */
  525.     public function getAcompteUpdate()
  526.     {
  527.         return $this->acompteUpdate;
  528.     }
  529.     
  530.     /**
  531.      * @param mixed $acompteUpdate
  532.      * @return CommandeSpeciale
  533.      */
  534.     public function setAcompteUpdate($acompteUpdate)
  535.     {
  536.         $this->acompteUpdate $acompteUpdate;
  537.         return $this;
  538.     }
  539.     
  540.     /**
  541.      * @return mixed
  542.      */
  543.     public function getDateRembourse()
  544.     {
  545.         return $this->dateRembourse;
  546.     }
  547.     
  548.     /**
  549.      * @param mixed $dateRembourse
  550.      * @return CommandeSpeciale
  551.      */
  552.     public function setDateRembourse($dateRembourse)
  553.     {
  554.         $this->dateRembourse $dateRembourse;
  555.         return $this;
  556.     }
  557.     public function getTotalCommande() {
  558.         if (empty($this->details)) {
  559.             return 0;
  560.         }
  561.         $total 0;
  562.         /** @var CommandeSpecialeDetail $detail */
  563.         foreach ($this->details as $detail) {
  564.             $total += $detail->getPvu() * $detail->getQuantite();
  565.         }
  566.         return $total;
  567.     }
  568. }