src/Entity/CommandeDetail.php line 16

Open in your IDE?
  1. <?php
  2. /**
  3.  * CommandeDetail.php
  4.  * Created by Stéphane Brun
  5.  * Date: 03/07/2018 at 15:21
  6.  */
  7. namespace App\Entity;
  8. use Doctrine\Common\Collections\ArrayCollection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. /**
  11.  * @ORM\Entity()
  12.  * @ORM\Table(name="commande_detail")
  13.  */
  14. class CommandeDetail
  15. {
  16.     const HISTORY_WATCH = array(
  17.         'quantiteCommandee' => 'Quantité commandé',
  18.     );
  19.     /**
  20.      * @ORM\Column(type="integer")
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue(strategy="AUTO")
  23.      */
  24.     protected $id;
  25.     /**
  26.      * has one Commande
  27.      *
  28.      * @ORM\ManyToOne(targetEntity="App\Entity\Commande", inversedBy="details")
  29.      * @ORM\JoinColumn(name="commande_id", referencedColumnName="id")
  30.      */
  31.     protected $commande;
  32.     /**
  33.      * has one CommandeSpecialeDetail
  34.      *
  35.      * @ORM\ManyToOne(targetEntity="App\Entity\CommandeSpecialeDetail")
  36.      * @ORM\JoinColumn(name="commande_speciale_detail_id", referencedColumnName="id", nullable=true)
  37.      */
  38.     protected $commandeSpecialeDetail;
  39.     /**
  40.      * has one Titre
  41.      *
  42.      * @ORM\ManyToOne(targetEntity="App\Entity\Titre")
  43.      * @ORM\JoinColumn(name="titre_id", referencedColumnName="TISBN")
  44.      */
  45.     protected $produit;
  46.     /**
  47.      * has one TitreCompany
  48.      *
  49.      * @ORM\ManyToOne(targetEntity="App\Entity\TitreCompany")
  50.      * @ORM\JoinColumn(name="titre_company_id", referencedColumnName="id")
  51.      */
  52.     protected $titreCompany;
  53.     /**
  54.      * has one Company
  55.      *
  56.      * @ORM\ManyToOne(targetEntity="App\Entity\Company")
  57.      * @ORM\JoinColumn(name="company_id", referencedColumnName="id")
  58.      */
  59.     protected $company;
  60.     /**
  61.      * @ORM\Column(name="quantite_commandee", type="integer", nullable=true)
  62.      */
  63.     protected $quantiteCommandee 0;
  64.     /**
  65.      * @ORM\Column(name="quantite_recue", type="integer", nullable=true)
  66.      */
  67.     protected $quantiteRecue 0;
  68.     /**
  69.      * @ORM\Column(name="pvu", type="float", nullable=true)
  70.      */
  71.     protected $pvu 0;
  72.     /**
  73.      * @ORM\Column(name="pu", type="float", nullable=true)
  74.      */
  75.     protected $pu;
  76.     /**
  77.      * @ORM\Column(name="titre", type="string", length=150, nullable=true)
  78.      */
  79.     protected $titre;
  80.     /**
  81.      * @ORM\Column(name="remise", type="integer", nullable=true)
  82.      */
  83.     protected $remise 0;
  84.     /**
  85.      * @ORM\Column(name="garder_notes", type="boolean")
  86.      */
  87.     protected $garderNotes false;
  88.     /**
  89.      * @ORM\Column(name="recu_bon", type="string", length=50, nullable=true)
  90.      */
  91.     protected $recuBon;
  92.     /**
  93.      * @ORM\Column(name="note", type="integer")
  94.      */
  95.     protected $note false;
  96.     /**
  97.      * has one CommandeReponse
  98.      *
  99.      * @ORM\ManyToOne(targetEntity="App\Entity\CommandeReponse")
  100.      * @ORM\JoinColumn(name="reponse", referencedColumnName="id")
  101.      */
  102.     protected $reponse;
  103.     /**
  104.      * @ORM\Column(name="date_limite", type="datetime", nullable=true)
  105.      */
  106.     protected $dateLimite;
  107.     /**
  108.      * @ORM\OneToMany(targetEntity="ReceptionDetail", mappedBy="originalCommandeDetail")
  109.      */
  110.     private $receptionDetail;
  111.     /**
  112.      * @return mixed
  113.      */
  114.     public function getId()
  115.     {
  116.         return $this->id;
  117.     }
  118.     /**
  119.      * @param mixed $id
  120.      * @return CommandeDetail
  121.      */
  122.     public function setId($id)
  123.     {
  124.         $this->id $id;
  125.         return $this;
  126.     }
  127.     /**
  128.      * @return Commande
  129.      */
  130.     public function getCommande()
  131.     {
  132.         return $this->commande;
  133.     }
  134.     /**
  135.      * @param mixed $commande
  136.      * @return CommandeDetail
  137.      */
  138.     public function setCommande(Commande $commande)
  139.     {
  140.         $this->commande $commande;
  141.         return $this;
  142.     }
  143.     /**
  144.      * @return CommandeSpecialeDetail
  145.      */
  146.     public function getCommandeSpecialeDetail()
  147.     {
  148.         return $this->commandeSpecialeDetail;
  149.     }
  150.     /**
  151.      * @param CommandeSpecialeDetail $commandeSpecialeDetail
  152.      * @return CommandeDetail
  153.      */
  154.     public function setCommandeSpecialeDetail(CommandeSpecialeDetail $commandeSpecialeDetail=null)
  155.     {
  156.         $this->commandeSpecialeDetail $commandeSpecialeDetail;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return Titre
  161.      */
  162.     public function getProduit()
  163.     {
  164.         return $this->produit;
  165.     }
  166.     /**
  167.      * @param Titre $produit
  168.      * @return CommandeDetail
  169.      */
  170.     public function setProduit(Titre $produit)
  171.     {
  172.         $this->produit $produit;
  173.         return $this;
  174.     }
  175.     /**
  176.      * @return Company
  177.      */
  178.     public function getCompany()
  179.     {
  180.         return $this->company;
  181.     }
  182.     /**
  183.      * @param Company $company
  184.      * @return CommandeDetail
  185.      */
  186.     public function setCompany(Company $company)
  187.     {
  188.         $this->company $company;
  189.         return $this;
  190.     }
  191.     /**
  192.      * @return mixed
  193.      */
  194.     public function getQuantiteCommandee()
  195.     {
  196.         return $this->quantiteCommandee;
  197.     }
  198.     /**
  199.      * @param mixed $quantiteCommandee
  200.      * @return CommandeDetail
  201.      */
  202.     public function setQuantiteCommandee($quantiteCommandee)
  203.     {
  204.         $this->quantiteCommandee $quantiteCommandee;
  205.         return $this;
  206.     }
  207.     /**
  208.      * @return mixed
  209.      */
  210.     public function getQuantiteRecue()
  211.     {
  212.         return $this->quantiteRecue;
  213.     }
  214.     /**
  215.      * @param mixed $quantiteRecue
  216.      * @return CommandeDetail
  217.      */
  218.     public function setQuantiteRecue($quantiteRecue)
  219.     {
  220.         $this->quantiteRecue $quantiteRecue;
  221.         return $this;
  222.     }
  223.     /**
  224.      * @return mixed
  225.      */
  226.     public function getPvu()
  227.     {
  228.         return $this->pvu;
  229.     }
  230.     /**
  231.      * @param mixed $pvu
  232.      * @return CommandeDetail
  233.      */
  234.     public function setPvu($pvu)
  235.     {
  236.         $this->pvu $pvu;
  237.         return $this;
  238.     }
  239.     /**
  240.      * @return mixed
  241.      */
  242.     public function getPu()
  243.     {
  244.         return $this->pu;
  245.     }
  246.     /**
  247.      * @param mixed $pu
  248.      * @return CommandeDetail
  249.      */
  250.     public function setPu($pu)
  251.     {
  252.         $this->pu $pu;
  253.         return $this;
  254.     }
  255.     /**
  256.      * @return mixed
  257.      */
  258.     public function getTitre()
  259.     {
  260.         return $this->titre;
  261.     }
  262.     /**
  263.      * @param mixed $titre
  264.      * @return CommandeDetail
  265.      */
  266.     public function setTitre($titre)
  267.     {
  268.         $this->titre $titre;
  269.         return $this;
  270.     }
  271.     /**
  272.      * @return mixed
  273.      */
  274.     public function getRemise()
  275.     {
  276.         return $this->remise;
  277.     }
  278.     /**
  279.      * @param mixed $remise
  280.      * @return CommandeDetail
  281.      */
  282.     public function setRemise($remise)
  283.     {
  284.         $this->remise $remise;
  285.         return $this;
  286.     }
  287.     /**
  288.      * @return mixed
  289.      */
  290.     public function getGarderNotes()
  291.     {
  292.         return $this->garderNotes;
  293.     }
  294.     /**
  295.      * @param mixed $garderNotes
  296.      * @return CommandeDetail
  297.      */
  298.     public function setGarderNotes($garderNotes)
  299.     {
  300.         $this->garderNotes $garderNotes;
  301.         return $this;
  302.     }
  303.     /**
  304.      * @return mixed
  305.      */
  306.     public function getRecuBon()
  307.     {
  308.         return $this->recuBon;
  309.     }
  310.     /**
  311.      * @param mixed $recuBon
  312.      * @return CommandeDetail
  313.      */
  314.     public function setRecuBon($recuBon)
  315.     {
  316.         $this->recuBon $recuBon;
  317.         return $this;
  318.     }
  319.     /**
  320.      * @return mixed
  321.      */
  322.     public function getNote()
  323.     {
  324.         return $this->note;
  325.     }
  326.     /**
  327.      * @param mixed $note
  328.      * @return CommandeDetail
  329.      */
  330.     public function setNote($note)
  331.     {
  332.         $this->note $note;
  333.         return $this;
  334.     }
  335.     /**
  336.      * @return mixed
  337.      */
  338.     public function getReponse()
  339.     {
  340.         return $this->reponse;
  341.     }
  342.     /**
  343.      * @param mixed $reponse
  344.      * @return CommandeDetail
  345.      */
  346.     public function setReponse($reponse)
  347.     {
  348.         $this->reponse $reponse;
  349.         return $this;
  350.     }
  351.     /**
  352.      * @return mixed
  353.      */
  354.     public function getDateLimite()
  355.     {
  356.         return $this->dateLimite;
  357.     }
  358.     /**
  359.      * @param mixed $dateLimite
  360.      * @return CommandeDetail
  361.      */
  362.     public function setDateLimite($dateLimite)
  363.     {
  364.         $this->dateLimite $dateLimite;
  365.         return $this;
  366.     }
  367.     /**
  368.      * @return TitreCompany
  369.      */
  370.     public function getTitreCompany()
  371.     {
  372.         return $this->titreCompany;
  373.     }
  374.     /**
  375.      * @param TitreCompany $titreCompany
  376.      * @return CommandeDetail
  377.      */
  378.     public function setTitreCompany(TitreCompany $titreCompany)
  379.     {
  380.         $this->titreCompany $titreCompany;
  381.         return $this;
  382.     }
  383.     /**
  384.      * @return mixed
  385.      */
  386.     public function getReceptionDetail()
  387.     {
  388.         return $this->receptionDetail;
  389.     }
  390.     /**
  391.      * @param mixed $receptionDetail
  392.      */
  393.     public function setReceptionDetail($receptionDetail): void
  394.     {
  395.         $this->receptionDetail $receptionDetail;
  396.     }
  397.     public function getDisponibilite()
  398.     {
  399.         $disp $this->getTitreCompany()->getQem()
  400.               - $this->getTitreCompany()->getQManquante()
  401.               - $this->getTitreCompany()->getQMisDeCote()
  402.               - $this->getTitreCompany()->getQAbimes()
  403.         ;
  404.         return $disp;
  405.     }
  406.     public function getReponseTexte()
  407.     {
  408.         /** @var CommandeReponse $reponse */
  409.         if (!empty($this->getReponse())) {
  410.             return $this->getReponse()->getDescription();
  411.         }
  412.         return '';
  413. //        switch ($this->getReponse()) {
  414. //            default:
  415. //            case 0:
  416. //                $texte = "Disponible";
  417. //                break;
  418. //            case 1:
  419. //                $texte = "Épuisé";
  420. //                break;
  421. //            case 2:
  422. //                $texte = "Non noté";
  423. //                break;
  424. //            case 3:
  425. //                $texte = "Réimp noté";
  426. //                break;
  427. //            case 4:
  428. //                $texte = "Sur commande";
  429. //                break;
  430. //            case 5:
  431. //                $texte = "Solde";
  432. //                break;
  433. //            case 6:
  434. //                $texte = "Réimp non noté";
  435. //                break;
  436. //            case 7:
  437. //                $texte = "Noté";
  438. //                break;
  439. //            case 15:
  440. //                $texte = "Substitution";
  441. //                break;
  442. //            case 11:
  443. //                $texte = "Abîmés";
  444. //                break;
  445. //            case 12:
  446. //                $texte = "Arrêt commercialisation";
  447. //                break;
  448. //        }
  449. //        return $texte;
  450.     }
  451.     public function getBrut()
  452.     {
  453.         return $this->getProduit()->getCoutant() * $this->getQuantiteCommandee();
  454.     }
  455.     public function __toString()
  456.     {
  457.         return (string)$this->getId();
  458.     }
  459. }