src/Entity/Main/Reservation.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Main;
  3. use App\Entity\Main\BookedActivity;
  4. use App\Entity\Customer\Customer;
  5. use App\Service\CustomerService;
  6. use App\Repository\ReservationRepository;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Doctrine\ORM\EntityManager;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Persistence\ManagerRegistry;
  11. use App\Service\Tools;
  12. /**
  13.  * @ORM\Entity(repositoryClass=ReservationRepository::class)
  14.  */
  15. class Reservation
  16. {
  17.     /**
  18.      * @ORM\Id
  19.      * @ORM\GeneratedValue
  20.      * @ORM\Column(type="integer")
  21.      */
  22.     private $id;
  23.     /**
  24.      * @ORM\Column(type="integer", nullable=false)
  25.      */
  26.     private $customer_id;
  27.     /**
  28.      * @var Customer
  29.      */
  30.     private $customer;
  31.     /**
  32.      * @ORM\Column(type="string", length=14, nullable=true)
  33.      */
  34.     private $customerNumber;
  35.     /**
  36.      * @ORM\Column(type="string", length=64)
  37.      */
  38.     private $formule;
  39.     /**
  40.      * @ORM\Column(type="string", length=64, nullable=true)
  41.      */
  42.     private $formuleCode;
  43.     /**
  44.      * @ORM\Column(type="string", length=255)
  45.      */
  46.     private $firstname;
  47.     /**
  48.      * @ORM\Column(type="string", length=255)
  49.      */
  50.     private $lastname;
  51.     /**
  52.      * @ORM\Column(type="string", length=255, nullable=true)
  53.      */
  54.     private $company;
  55.     /**
  56.      * @ORM\Column(type="string", length=255)
  57.      */
  58.     private $email;
  59.     /**
  60.      * @ORM\Column(type="string", length=32, nullable=true)
  61.      */
  62.     private $phone;
  63.     /**
  64.      * @ORM\Column(type="string", length=32, nullable=true)
  65.      */
  66.     private $phoneMobile;
  67.     /**
  68.      * @ORM\Column(type="text", nullable=true)
  69.      */
  70.     private $billingAddress;
  71.     /**
  72.      * @ORM\Column(type="text", nullable=true)
  73.      */
  74.     private $comment;
  75.     /**
  76.      * @ORM\Column(type="datetime")
  77.      */
  78.     private $dateAdd;
  79.     /**
  80.      * @ORM\Column(type="datetime")
  81.      */
  82.     private $dateResa;
  83.     /**
  84.      * @ORM\Column(type="string", length=12, nullable=true)
  85.      */
  86.     private $numeroResa;
  87.     /**
  88.      * @ORM\Column(type="string", length=12, nullable=true)
  89.      */
  90.     private $invoiceNumber;
  91.     /**
  92.      * @ORM\Column(type="float", nullable=true)
  93.      */
  94.     private $sstotalHT;
  95.     /**
  96.      * @ORM\Column(type="float", nullable=true)
  97.      */
  98.     private $TVA;
  99.     /**
  100.      * @ORM\Column(type="float", nullable=true)
  101.      */
  102.     private $totalTTC;
  103.     /**
  104.      * @ORM\Column(type="text", nullable=true)
  105.      */
  106.     private $history;
  107.     /**
  108.      * @ORM\Column(type="datetime")
  109.      */
  110.     private $dateUpd;
  111.     /**
  112.      * @ORM\Column(type="string", length=128, nullable=true)
  113.      */
  114.     private $statut;
  115.     /**
  116.      * @ORM\Column(type="boolean", nullable=true)
  117.      */
  118.     private $active;
  119.     /**
  120.      * @ORM\Column(type="boolean", nullable=true)
  121.      */
  122.     private $confirmation;
  123.     /**
  124.      * @ORM\Column(type="boolean", nullable=true)
  125.      */
  126.     private $deleted;
  127.     /**
  128.      * @ORM\Column(type="boolean", nullable=true)
  129.      */
  130.     private $composted;
  131.     /**
  132.      * @ORM\Column(type="string", length=20, nullable=true)
  133.      */
  134.     private $ip;
  135.     
  136.     /**
  137.      * @ORM\Column(type="string", length=255, nullable=true)
  138.      */
  139.     private $payment_id;
  140.     
  141.     /**
  142.      * @var bookedActivity[]
  143.      *
  144.      * @ORM\OneToMany(targetEntity="App\Entity\Main\BookedActivity", mappedBy="reservation", cascade={"persist","remove"})
  145.      */
  146.     private $bookedActivity;
  147.     
  148.     /**
  149.      * @var reservationDetails[]
  150.      *
  151.      * @ORM\OneToMany(targetEntity="App\Entity\Main\ReservationDetails", mappedBy="reservation", cascade={"persist","remove"})
  152.      */
  153.     private $reservationDetails;    
  154.     
  155.     /**
  156.      * @var historyResa[]
  157.      *
  158.      * @ORM\OneToMany(targetEntity="App\Entity\Main\History", mappedBy="reservation", cascade={"persist","remove"})
  159.      */
  160.     private $historyResa;
  161.     /**
  162.      * @ORM\Column(type="text", nullable=true)
  163.      */
  164.     private $childName;
  165.     /**
  166.      * @ORM\Column(type="text", nullable=true)
  167.      */
  168.     private $childBirthday;
  169.     /**
  170.      * @ORM\Column(type="text", nullable=true)
  171.      */
  172.     private $childAge;
  173.     
  174.     private $paye;
  175.     private $restedu;
  176.     protected $em;
  177.     private $cs;
  178.     private $doctrine;
  179.     /**
  180.      * @ORM\Column(type="text", nullable=true)
  181.      */
  182.     private $birthday_customer_comment;
  183.     public function __toString()
  184.     {
  185.         return (string) $this->numeroResa;
  186.     }
  187.     
  188.     /**
  189.      * Constructor
  190.      */
  191.     public function __construct()
  192.     {
  193.         $dateTimeZone = new \DateTimeZone('Europe/Paris'); 
  194.         $this->dateAdd = new \DateTime('now'$dateTimeZone);
  195.         $this->dateUpd = new \DateTime('now'$dateTimeZone);
  196.         $this->bookedActivity = new ArrayCollection();
  197.         $this->historyResa = new ArrayCollection();
  198.         $this->numeroResa $this->generateReference();
  199.         // $this->cs = new CustomerService;
  200.         // $this->em = $entityManager;
  201.         // $doctrine = new ManagerRegistry();
  202.         // $this->em = $doctrine->getManager('customer');
  203.         // $this->customer = $this->em->getRepository(Customer::class)->find($this->getCustomerId());
  204.         // $this->setCustomer($this->getCustomerId());
  205.     }
  206.     public function getId(): ?int
  207.     {
  208.         return $this->id;
  209.     }
  210.     public function getCustomerId()
  211.     {
  212.         return $this->customer_id;
  213.     }
  214.     public function setCustomerId(?int $customer_id): self
  215.     {
  216.         $this->customer_id $customer_id;
  217.         return $this;
  218.     }
  219.     public function getCustomer()
  220.     {
  221.         return $this->customer;
  222.     }
  223.     public function setCustomer(?Customer $customer): self
  224.     {
  225.         $this->customer $customer;
  226.         return $this;
  227.     }
  228.     public function getCustomerNumber(): ?string
  229.     {
  230.         return $this->customerNumber;
  231.     }
  232.     public function setCustomerNumber(?string $customerNumber): self
  233.     {
  234.         $this->customerNumber $customerNumber;
  235.         return $this;
  236.     }
  237.     public function getFormule(): ?string
  238.     {
  239.         return $this->formule;
  240.     }
  241.     public function setFormule(string $formule): self
  242.     {
  243.         $this->formule $formule;
  244.         return $this;
  245.     }
  246.     public function getFormuleCode(): ?string
  247.     {
  248.         return $this->formuleCode;
  249.     }
  250.     public function setFormuleCode(?string $formuleCode): self
  251.     {
  252.         $this->formuleCode $formuleCode;
  253.         return $this;
  254.     }
  255.     public function getFirstname(): ?string
  256.     {
  257.         return $this->firstname;
  258.     }
  259.     public function setFirstname(string $firstname): self
  260.     {
  261.         $this->firstname $firstname;
  262.         return $this;
  263.     }
  264.     public function getLastname(): ?string
  265.     {
  266.         return $this->lastname;
  267.     }
  268.     public function setLastname(string $lastname): self
  269.     {
  270.         $this->lastname $lastname;
  271.         return $this;
  272.     }
  273.     public function getCompany(): ?string
  274.     {
  275.         return $this->company;
  276.     }
  277.     public function setCompany(?string $company): self
  278.     {
  279.         $this->company $company;
  280.         return $this;
  281.     }
  282.     public function getEmail(): ?string
  283.     {
  284.         return $this->email;
  285.     }
  286.     public function setEmail(string $email): self
  287.     {
  288.         $this->email $email;
  289.         return $this;
  290.     }
  291.     public function getPhone(): ?string
  292.     {
  293.         return $this->phone;
  294.     }
  295.     public function setPhone(?string $phone): self
  296.     {
  297.         $this->phone $phone;
  298.         return $this;
  299.     }
  300.     public function getPhoneMobile(): ?string
  301.     {
  302.         return $this->phoneMobile;
  303.     }
  304.     public function setPhoneMobile(?string $phoneMobile): self
  305.     {
  306.         $this->phoneMobile $phoneMobile;
  307.         return $this;
  308.     }
  309.     public function getBillingAddress(): ?string
  310.     {
  311.         return $this->billingAddress;
  312.     }
  313.     public function setBillingAddress(?string $billingAddress): self
  314.     {
  315.         $this->billingAddress $billingAddress;
  316.         return $this;
  317.     }
  318.     public function getComment(): ?string
  319.     {
  320.         return $this->comment;
  321.     }
  322.     public function setComment(?string $comment): self
  323.     {
  324.         $this->comment $comment;
  325.         return $this;
  326.     }
  327.     public function getDateAdd(): ?\DateTimeInterface
  328.     {
  329.         return $this->dateAdd;
  330.     }
  331.     public function setDateAdd(\DateTimeInterface $dateAdd): self
  332.     {
  333.         $this->dateAdd $dateAdd;
  334.         return $this;
  335.     }
  336.     public function getDateResa(): ?\DateTimeInterface
  337.     {
  338.         return $this->dateResa;
  339.     }
  340.     public function setDateResa(\DateTimeInterface $dateResa): self
  341.     {
  342.         $this->dateResa $dateResa;
  343.         return $this;
  344.     }
  345.     public function getNumeroResa(): ?string
  346.     {
  347.         return $this->numeroResa;
  348.     }
  349.     public function setNumeroResa(?string $numeroResa): self
  350.     {
  351.         $this->numeroResa $numeroResa;
  352.         return $this;
  353.     }
  354.     public function getInvoiceNumber(): ?string
  355.     {
  356.         return $this->invoiceNumber;
  357.     }
  358.     public function setInvoiceNumber(?string $invoiceNumber): self
  359.     {
  360.         $this->invoiceNumber $invoiceNumber;
  361.         return $this;
  362.     }
  363.     public function getSstotalHT(): ?float
  364.     {
  365.         return $this->sstotalHT;
  366.     }
  367.     public function setSstotalHT(?float $sstotalHT): self
  368.     {
  369.         $this->sstotalHT $sstotalHT;
  370.         return $this;
  371.     }
  372.     public function getTVA(): ?float
  373.     {
  374.         return $this->TVA;
  375.     }
  376.     public function setTVA(?float $TVA): self
  377.     {
  378.         $this->TVA $TVA;
  379.         return $this;
  380.     }
  381.     public function getTotalTTC(): ?float
  382.     {
  383.         return $this->totalTTC;
  384.     }
  385.     public function setTotalTTC(?float $totalTTC): self
  386.     {
  387.         $this->totalTTC $totalTTC;
  388.         return $this;
  389.     }
  390.     public function getHistory(): ?string
  391.     {
  392.         return $this->history;
  393.     }
  394.     public function setHistory(?string $history): self
  395.     {
  396.         $this->history $history;
  397.         return $this;
  398.     }
  399.     public function getDateUpd(): ?\DateTimeInterface
  400.     {
  401.         return $this->dateUpd;
  402.     }
  403.     public function setDateUpd(\DateTimeInterface $dateUpd): self
  404.     {
  405.         $this->dateUpd $dateUpd;
  406.         return $this;
  407.     }
  408.     public function getStatut(): ?string
  409.     {
  410.         return $this->statut;
  411.     }
  412.     public function setStatut(?string $statut): self
  413.     {
  414.         $this->statut $statut;
  415.         return $this;
  416.     }
  417.     public function getActive(): ?bool
  418.     {
  419.         return $this->active;
  420.     }
  421.     public function setActive(?bool $active): self
  422.     {
  423.         $this->active $active;
  424.         return $this;
  425.     }
  426.     public function getConfirmation(): ?bool
  427.     {
  428.         return $this->confirmation;
  429.     }
  430.     public function setConfirmation(?bool $confirmation): self
  431.     {
  432.         $this->confirmation $confirmation;
  433.         return $this;
  434.     }
  435.     public function getDeleted(): ?bool
  436.     {
  437.         return $this->deleted;
  438.     }
  439.     public function setDeleted(?bool $deleted): self
  440.     {
  441.         $this->deleted $deleted;
  442.         return $this;
  443.     }
  444.     public function getComposted(): ?bool
  445.     {
  446.         return $this->composted;
  447.     }
  448.     public function setComposted(?bool $composted): self
  449.     {
  450.         $this->composted $composted;
  451.         return $this;
  452.     }
  453.     public function getChildName(): ?string
  454.     {
  455.         return $this->childName;
  456.     }
  457.     public function setChildName(?string $childName): self
  458.     {
  459.         $this->childName $childName;
  460.         return $this;
  461.     }
  462.     public function getChildBirthday(): ?string
  463.     {
  464.         return $this->childBirthday;
  465.     }
  466.     public function setChildBirthday(string $childBirthday): self
  467.     {
  468.         $this->childBirthday $childBirthday;
  469.         return $this;
  470.     }
  471.     public function getChildAge(): ?string
  472.     {
  473.         return $this->childAge;
  474.     }
  475.     public function setChildAge(?string $childAge): self
  476.     {
  477.         $this->childAge $childAge;
  478.         return $this;
  479.     }
  480.     public function getIp(): ?string
  481.     {
  482.         return $this->ip;
  483.     }
  484.     public function setIp(?string $ip): self
  485.     {
  486.         $this->ip $ip;
  487.         return $this;
  488.     }
  489.     public function getPaymentId(): ?string
  490.     {
  491.         return $this->payment_id;
  492.     }
  493.     public function setPaymentId(?string $payment_id): self
  494.     {
  495.         $this->payment_id $payment_id;
  496.         return $this;
  497.     }
  498.     
  499.     /**
  500.      * @param bookedActivity[] $bookedActivity
  501.      */
  502.     public function setBookedActivity($bookedActivity)
  503.     {
  504.         $this->bookedActivity $bookedActivity;
  505.     }
  506.     /**
  507.      * @return bookedActivity[]
  508.      */
  509.     public function getBookedActivity()
  510.     {
  511.         return $this->bookedActivity;
  512.     }
  513.     /**
  514.      * @param reservationDetails[] $reservationDetails
  515.      */
  516.     public function setReservationDetails($reservationDetails)
  517.     {
  518.         $this->reservationDetails $reservationDetails;
  519.     }
  520.     /**
  521.      * @return reservationDetails[]
  522.      */
  523.     public function getReservationDetails()
  524.     {
  525.         return $this->reservationDetails;
  526.     }   
  527.     
  528.     /**
  529.      * @param historyResa[] $historyResa
  530.      */
  531.     public function setHistoryResa($historyResa)
  532.     {
  533.         $this->historyResa $historyResa;
  534.     }
  535.     /**
  536.      * @return bookedActivity[]
  537.      */
  538.     public function getHistoryResa()
  539.     {
  540.         return $this->historyResa;
  541.     }
  542.     
  543.     /**
  544.      * Generate a unique reference for orders generated
  545.      * @return String
  546.      */
  547.     public function generateReference()
  548.     {
  549.         return strtoupper(Tools::passwdGen(6'NO_NUMERIC'));
  550.     }
  551.         
  552.     public function getSolde() {
  553.         $customer $this->getCustomer();       
  554.         if ($customer instanceof Customer) {
  555.             return $customer->getSolde();
  556.         } else {
  557.             return 0;
  558.         }
  559.     }
  560.     
  561.     public function getBirthday() {
  562.         $customer $this->getCustomer();
  563.         if ($customer instanceof Customer) {
  564.             return $customer->getBirthday();
  565.         } else {
  566.             $dateTimeZone = new \DateTimeZone('Europe/Paris'); 
  567.             return new \DateTime('01-01-1901'$dateTimeZone);
  568.         }
  569.     }
  570.     
  571.     public function getPaye() {
  572.         $this->paye 0;
  573.         
  574.         foreach($this->historyResa as $history)
  575.         {
  576.             if( preg_match('/^Paiement/'$history->getInformation()) ) $this->paye += $history->getMouvement();
  577.         }
  578.         // return (float) number_format($this->paye, 2, '.', ' ') . ' €';
  579.         return (float) number_format($this->paye2'.'' ');
  580.     }
  581.     
  582.     public function getRestedu() {
  583.         $this->restedu 0;
  584.         foreach($this->historyResa as $history)
  585.         {
  586.             $this->restedu += $history->getMouvement();
  587.         }
  588.         $this->restedu round($this->restedu2);
  589.         
  590.         // return (float) number_format($this->restedu, 2, '.', ' ') . ' €';
  591.         return (float) number_format($this->restedu2'.'' ');
  592.     }
  593.     public function getBirthdayCustomerComment(): ?string
  594.     {
  595.         return $this->birthday_customer_comment;
  596.     }
  597.     public function setBirthdayCustomerComment(?string $birthday_customer_comment): self
  598.     {
  599.         $this->birthday_customer_comment $birthday_customer_comment;
  600.         return $this;
  601.     }
  602. }