Deprecated: Constant E_STRICT is deprecated in /var/www/PixelForce/vendor/symfony/error-handler/ErrorHandler.php on line 58

Deprecated: Constant E_STRICT is deprecated in /var/www/PixelForce/vendor/symfony/error-handler/ErrorHandler.php on line 76
Symfony Profiler

src/Entity/OrderSecu.php line 377

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\OrderSecuRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\EntityManager;
  8. use Doctrine\ORM\EntityManagerInterface;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use JsonSerializable;
  11. /**
  12.  * @ORM\Entity(repositoryClass=OrderSecuRepository::class)
  13.  */
  14. class OrderSecu implements JsonSerializable
  15. {
  16.     public const CREATED 100;
  17.     public const PAIED 1;
  18.     public const VALIDATED 2;
  19.     public const REJECTED = -1;
  20.     public const STATUS = [
  21.         self::CREATED => "Créée"
  22.         self::PAIED => "Payée",
  23.         self::VALIDATED => "Livrée",
  24.         self::REJECTED => "Rejetée"
  25.     ];
  26.     public const STATUS_DATA_FORM = [
  27.         "Créée" => self::CREATED
  28.         "Payée" => self::PAIED,
  29.         "Livrée" => self::VALIDATED,
  30.         "Rejetée" => self::REJECTED
  31.     ];
  32.     /**
  33.      * @ORM\Id
  34.      * @ORM\GeneratedValue
  35.      * @ORM\Column(type="integer")
  36.      */
  37.     private $id;
  38.     /**
  39.      * @ORM\ManyToOne(targetEntity=ProduitSecu::class)
  40.      * @ORM\JoinColumn(nullable=true)
  41.      */
  42.     private $produit;
  43.     /**
  44.      * @ORM\ManyToOne(targetEntity=TypeAbonnementSecu::class)
  45.      * @ORM\JoinColumn(nullable=true)
  46.      */
  47.     private $typeAbonnement;
  48.     /**
  49.      * @ORM\Column(type="string", length=255, nullable=true)
  50.      */
  51.     private $codePromo;
  52.     /**
  53.      * @ORM\Column(type="float")
  54.      */
  55.     private $prixProduit;
  56.     /**
  57.      * @ORM\Column(type="integer")
  58.      */
  59.     private $statut;
  60.     /**
  61.      * @ORM\ManyToOne(targetEntity=User::class)
  62.      * @ORM\JoinColumn(nullable=false)
  63.      */
  64.     private $agent;
  65.     /**
  66.      * @ORM\ManyToOne(targetEntity=User::class)
  67.      * @ORM\JoinColumn(nullable=false)
  68.      */
  69.     private $client;
  70.     private $sessionKey;
  71.     /**
  72.      * @ORM\OneToMany(targetEntity=OrderSecuAccomp::class, mappedBy="orderSecu")
  73.      */
  74.     private $accomps;
  75.     private $accompsSession;
  76.     /**
  77.      * @ORM\ManyToOne(targetEntity=TypeInstallationSecu::class)
  78.      * @ORM\JoinColumn(nullable=true)
  79.      */
  80.     private $typeInstallation;
  81.     /**
  82.      * @ORM\ManyToOne(targetEntity=Secteur::class)
  83.      * @ORM\JoinColumn(nullable=false)
  84.      */
  85.     private $secteur;
  86.     /**
  87.      * @ORM\Column(type="datetime")
  88.      */
  89.     private $dateCommande;
  90.     /**
  91.      * @ORM\Column(type="float", nullable=true)
  92.      */
  93.     private $installationFrais;
  94.     /**
  95.      * @ORM\Column(type="float")
  96.      */
  97.     private $accompMontant;
  98.     /**
  99.      * @ORM\Column(type="string", length=255)
  100.      */
  101.     private $chargeId;
  102.     /**
  103.      * @ORM\Column(type="string", length=500, nullable=true)
  104.      */
  105.     private $contratRempli;
  106.     /**
  107.      * @ORM\Column(type="string", length=500, nullable=true)
  108.      */
  109.     private $contratSigned;
  110.     /**
  111.      * @ORM\Column(type="json", nullable=true)
  112.      */
  113.     private $sepa = [];
  114.     /**
  115.      * @ORM\ManyToOne(targetEntity=KitBaseSecu::class)
  116.      */
  117.     private $kitbase;
  118.     /**
  119.      * @ORM\ManyToOne(targetEntity=TvaSecu::class)
  120.      */
  121.     private $tva;
  122.     /**
  123.      * @ORM\Column(type="decimal", precision=5, scale=2, nullable=true)
  124.      */
  125.     private $tvaPourcentage;
  126.     /**
  127.      * @ORM\Column(type="string", length=255, nullable=true)
  128.      */
  129.     private $invoicePath;
  130.     
  131.     public function __construct()
  132.     {
  133.         $this->accomps = new ArrayCollection();
  134.         $this->accompsSession = [];
  135.     }
  136.     public function getId(): ?int
  137.     {
  138.         return $this->id;
  139.     }
  140.     public function getProduit(): ?ProduitSecu
  141.     {
  142.         return $this->produit;
  143.     }
  144.     public function setProduit(?ProduitSecu $produit): self
  145.     {
  146.         $this->produit $produit;
  147.         return $this;
  148.     }
  149.     public function getTypeAbonnement(): ?TypeAbonnementSecu
  150.     {
  151.         return $this->typeAbonnement;
  152.     }
  153.     public function setTypeAbonnement(?TypeAbonnementSecu $typeAbonnement): self
  154.     {
  155.         $this->typeAbonnement $typeAbonnement;
  156.         return $this;
  157.     }
  158.     public function getCodePromo(): ?string
  159.     {
  160.         return $this->codePromo;
  161.     }
  162.     public function setCodePromo(?string $codePromo): self
  163.     {
  164.         $this->codePromo $codePromo;
  165.         return $this;
  166.     }
  167.     public function getPrixProduit(): ?float
  168.     {
  169.         return $this->prixProduit;
  170.     }
  171.     public function setPrixProduit(float $prixProduit): self
  172.     {
  173.         $this->prixProduit $prixProduit;
  174.         return $this;
  175.     }
  176.     public function getStatut(): ?int
  177.     {
  178.         return $this->statut;
  179.     }
  180.     public function setStatut(int $statut): self
  181.     {
  182.         $this->statut $statut;
  183.         return $this;
  184.     }
  185.     public function getAgent(): ?User
  186.     {
  187.         return $this->agent;
  188.     }
  189.     public function setAgent(?User $agent): self
  190.     {
  191.         $this->agent $agent;
  192.         return $this;
  193.     }
  194.     public function getClient(): ?User
  195.     {
  196.         return $this->client;
  197.     }
  198.     public function setClient(?User $client): self
  199.     {
  200.         $this->client $client;
  201.         return $this;
  202.     }
  203.     /**
  204.      * Get the value of sessionKey
  205.      */ 
  206.     public function getSessionKey()
  207.     {
  208.         return $this->sessionKey;
  209.     }
  210.     /**
  211.      * Set the value of sessionKey
  212.      *
  213.      * @return  self
  214.      */ 
  215.     public function setSessionKey($sessionKey)
  216.     {
  217.         $this->sessionKey $sessionKey;
  218.         return $this;
  219.     }
  220.     /**
  221.      * @return Collection<int, OrderSecuAccomp>
  222.      */
  223.     public function getAccomps(): Collection
  224.     {
  225.         return $this->accomps;
  226.     }
  227.     public function addAccomp(OrderSecuAccomp $accomp): self
  228.     {
  229.         if (!$this->accomps->contains($accomp)) {
  230.             $this->accomps[] = $accomp;
  231.             $accomp->setOrderSecu($this);
  232.         }
  233.         return $this;
  234.     }
  235.     public function removeAccomp(OrderSecuAccomp $accomp): self
  236.     {
  237.         if ($this->accomps->removeElement($accomp)) {
  238.             // set the owning side to null (unless already changed)
  239.             if ($accomp->getOrderSecu() === $this) {
  240.                 $accomp->setOrderSecu(null);
  241.             }
  242.         }
  243.         return $this;
  244.     }
  245.     //session
  246.     public function add(OrderSecuAccomp $accomp){
  247.         $accompsSession $this->getAccompsSession();
  248.         $index $this->indexOf($accomp->getProduit()->getId());
  249.         if($index!=-1){
  250.             $qty $accompsSession[$index]->getQte() + $accomp->getQte();
  251.             $accomp->setQte($qty);
  252.             array_splice($accompsSession$index1);
  253.         } 
  254.         $accompsSession[] = $accomp;
  255.         $this->setAccompsSession($accompsSession);
  256.     }
  257.     public function indexOf($productId){
  258.         $index = -1;
  259.         $accompsSession $this->getAccompsSession();
  260.         for($i=0$i<count($accompsSession) ; $i++){
  261.             $accomp $accompsSession[$i];
  262.             
  263.             if($accomp->getProduit()->getId()==$productId) {
  264.                 $index $i;
  265.                 break;
  266.             }
  267.         }
  268.         return $index;
  269.     }
  270.     
  271.     // public function checkBasketItem(BasketItem $basketItem){
  272.     //     $basketItem->getProduit()->checkQty($basketItem->getQuantity());
  273.     // }
  274.     public function update(OrderSecuAccomp $accomp){
  275.         //$this->checkBasketItem($basketItem);
  276.         $accompsSession $this->getAccompsSession();
  277.         $index $this->indexOf($accomp->getProduit()->getId());
  278.         if($index!=-1array_splice($accompsSession$index1);
  279.         $accompsSession[] = $accomp;
  280.         $this->setAccompsSession($accompsSession);
  281.     }
  282.     public function remove($productId){
  283.         $accompsSession $this->getAccompsSession();
  284.         $index $this->indexOf($productId);
  285.         if($index!=-1)  array_splice($accompsSession$index1);
  286.         $this->setAccompsSession($accompsSession);
  287.     }
  288.     public function getMontantAccomp(){
  289.         $montant 0;
  290.         for($i=0$i<count($this->getAccompsSession()) ; $i++){
  291.             $montant += $this->getAccompsSession()[$i]->getMontant();
  292.         }  
  293.         return $montant;
  294.     }
  295.     public function getMontantHt(){
  296.         return $this->getPrixProduit() + $this->getMontantAccomp();
  297.     }
  298.     public function getMontantTva(){
  299.         return $this->getMontantHt() * $this->getTva()->getValeur()/100;
  300.     }
  301.     public function getMontantTtc(){
  302.         return $this->getMontantHt() + $this->getMontantTva();
  303.     }
  304.     public function jsonSerialize()
  305.     {
  306.         $vars get_object_vars($this);
  307.         return $vars;
  308.     }
  309.     /**
  310.      * Get the value of accompsSession
  311.      */ 
  312.     public function getAccompsSession()
  313.     {
  314.         return $this->accompsSession;
  315.     }
  316.     /**
  317.      * Set the value of accompsSession
  318.      *
  319.      * @return  self
  320.      */ 
  321.     public function setAccompsSession($accompsSession)
  322.     {
  323.         $this->accompsSession $accompsSession;
  324.         return $this;
  325.     }
  326.     public function getTypeInstallation(): ?TypeInstallationSecu
  327.     {
  328.         return $this->typeInstallation;
  329.     }
  330.     public function setTypeInstallation(?TypeInstallationSecu $typeInstallation): self
  331.     {
  332.         $this->typeInstallation $typeInstallation;
  333.         return $this;
  334.     }
  335.     public function getFraisInstallation(){
  336.         return $this->getTypeInstallation() ? $this->getTypeInstallation()->getPrix() : 0;
  337.     }
  338.     public function getSecteur(): ?Secteur
  339.     {
  340.         return $this->secteur;
  341.     }
  342.     public function setSecteur(?Secteur $secteur): self
  343.     {
  344.         $this->secteur $secteur;
  345.         return $this;
  346.     }
  347.     public function getDateCommande(): ?\DateTimeInterface
  348.     {
  349.         return $this->dateCommande;
  350.     }
  351.     public function setDateCommande(\DateTimeInterface $dateCommande): self
  352.     {
  353.         $this->dateCommande $dateCommande;
  354.         return $this;
  355.     }
  356.     
  357.     public function refresh(EntityManagerInterface $em){
  358.         /* if($this->getProduit()){
  359.             $this->setProduit($em->getRepository(ProduitSecu::class)->find($this->getProduit()->getId()));
  360.         }
  361.         if($this->getTypeAbonnement()){
  362.             $this->setTypeAbonnement($em->getRepository(TypeAbonnementSecu::class)->find($this->getTypeAbonnement()->getId()));
  363.         }
  364.         if($this->getTypeInstallation()){
  365.             $this->setTypeInstallation($em->getRepository(TypeInstallationSecu::class)->find($this->getTypeInstallation()->getId()));
  366.         } */
  367.         if($this->getKitbase()){
  368.             $this->setKitbase($em->getRepository(KitBaseSecu::class)->find($this->getKitbase()->getId()));
  369.         }
  370.         if($this->getTva()){
  371.             $this->setTva($em->getRepository(TvaSecu::class)->find($this->getTva()->getId()));
  372.         }
  373.     }
  374.     public function getInstallationFrais(): ?float
  375.     {
  376.         return $this->installationFrais;
  377.     }
  378.     public function setInstallationFrais(float $installationFrais): self
  379.     {
  380.         $this->installationFrais $installationFrais;
  381.         return $this;
  382.     }
  383.     public function getAccompMontant(): ?float
  384.     {
  385.         return $this->accompMontant;
  386.     }
  387.     public function setAccompMontant(float $accompMontant): self
  388.     {
  389.         $this->accompMontant $accompMontant;
  390.         return $this;
  391.     }
  392.     public function getChargeId(): ?string
  393.     {
  394.         return $this->chargeId;
  395.     }
  396.     public function setChargeId(string $chargeId): self
  397.     {
  398.         $this->chargeId $chargeId;
  399.         return $this;
  400.     }
  401.     public function getStatusStr(): ?string 
  402.     {
  403.         return OrderSecu::STATUS[$this->getStatut()];
  404.     }
  405.     public function getTotalHt(){
  406.         return $this->getPrixProduit() + $this->getAccompMontant();
  407.     }
  408.     public function getTvaMontantBase(){
  409.         return $this->getTotalHt() * $this->getTvaPourcentage()/100
  410.     }
  411.     public function getTotalTtc(){
  412.        return  $this->getTotalHt() + $this->getTvaMontantBase();
  413.     }
  414.     public function getContratRempli(): ?string
  415.     {
  416.         return $this->contratRempli;
  417.     }
  418.     public function setContratRempli(string $contratRempli): self
  419.     {
  420.         $this->contratRempli $contratRempli;
  421.         return $this;
  422.     }
  423.     public function getContratSigned(): ?string
  424.     {
  425.         return $this->contratSigned;
  426.     }
  427.     public function setContratSigned(?string $contratSigned): self
  428.     {
  429.         $this->contratSigned $contratSigned;
  430.         return $this;
  431.     }
  432.     public function getSepa(): ?array
  433.     {
  434.         return $this->sepa;
  435.     }
  436.     public function setSepa(?array $sepa): self
  437.     {
  438.         $this->sepa $sepa;
  439.         return $this;
  440.     }
  441.     public function getKitbase(): ?KitBaseSecu
  442.     {
  443.         return $this->kitbase;
  444.     }
  445.     public function setKitbase(?KitBaseSecu $kitbase): self
  446.     {
  447.         $this->kitbase $kitbase;
  448.         return $this;
  449.     }
  450.     public function getTva(): ?TvaSecu
  451.     {
  452.         return $this->tva;
  453.     }
  454.     public function setTva(?TvaSecu $tva): self
  455.     {
  456.         $this->tva $tva;
  457.         return $this;
  458.     }
  459.     public function getTvaPourcentage(): ?string
  460.     {
  461.         return $this->tvaPourcentage;
  462.     }
  463.     public function setTvaPourcentage(?string $tvaPourcentage): self
  464.     {
  465.         $this->tvaPourcentage $tvaPourcentage;
  466.         return $this;
  467.     }
  468.     public function getInvoicePath(): ?string
  469.     {
  470.         return $this->invoicePath;
  471.     }
  472.     public function setInvoicePath(?string $invoicePath): self
  473.     {
  474.         $this->invoicePath $invoicePath;
  475.         return $this;
  476.     }
  477. }