src/Aviatur/FlightBundle/Entity/Churning.php line 13

Open in your IDE?
  1. <?php
  2. namespace Aviatur\FlightBundle\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * Churning.
  6.  *
  7.  * @ORM\Table(name="churning", indexes={@ORM\Index(name="order_id", columns={"order_id"})})
  8.  * @ORM\Entity(repositoryClass="Aviatur\FlightBundle\Entity\ChurningRepository")
  9.  */
  10. class Churning
  11. {
  12.     /**
  13.      * @var int
  14.      *
  15.      * @ORM\Column(name="id", type="integer", nullable=false)
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue(strategy="IDENTITY")
  18.      */
  19.     private $id;
  20.     /**
  21.      *
  22.      * @ORM\ManyToOne(targetEntity="Aviatur\GeneralBundle\Entity\Order", inversedBy="churning")
  23.      * @ORM\JoinColumns({
  24.      *   @ORM\JoinColumn(name="order_id", referencedColumnName="id")
  25.      * })
  26.      */
  27.     private ?\Aviatur\GeneralBundle\Entity\Order $order null;
  28.     /**
  29.      * @ORM\Column(name="bookingDate", type="datetime", nullable=false)
  30.      */
  31.     private ?\DateTime $bookingdate null;
  32.     /**
  33.      * @ORM\Column(name="flightDate", type="datetime", nullable=false)
  34.      */
  35.     private ?\DateTime $flightdate null;
  36.     /**
  37.      * @ORM\Column(name="departureDate", type="datetime", nullable=false)
  38.      */
  39.     private ?\DateTime $departureDate null;
  40.     /**
  41.      * @ORM\Column(name="arrivalDate", type="datetime", nullable=false)
  42.      */
  43.     private ?\DateTime $arrivalDate null;
  44.     /**
  45.      * @ORM\Column(name="birthDate", type="datetime", nullable=true)
  46.      */
  47.     private ?\DateTime $birthdate null;
  48.     /**
  49.      * @ORM\Column(name="comment", type="string", nullable=true)
  50.      */
  51.     private $comment;
  52.     /**
  53.      * @var string
  54.      *
  55.      * @ORM\Column(name="flightNumber", type="string", nullable=true)
  56.      */
  57.     private $flightnumber;
  58.     /**
  59.      * @var string
  60.      *
  61.      * @ORM\Column(name="document", type="string", nullable=false)
  62.      */
  63.     private $document;
  64.     /**
  65.      * @var string
  66.      *
  67.      * @ORM\Column(name="name", type="string", nullable=false)
  68.      */
  69.     private $name;
  70.     /**
  71.      * @var int
  72.      *
  73.      * @ORM\Column(name="tryNumber", type="integer", nullable=false)
  74.      */
  75.     private $trynumber;
  76.     /**
  77.      * @var int
  78.      *
  79.      * @ORM\Column(name="enabled", type="integer", nullable=false)
  80.      */
  81.     private $enabled;
  82.     /**
  83.      * @ORM\OneToMany(targetEntity="Aviatur\FlightBundle\Entity\ChurningActivityLog", mappedBy="order", cascade={"all"})
  84.      */
  85.     private $churningActivityLog;
  86.     /**
  87.      * Constructor.
  88.      */
  89.     public function __construct()
  90.     {
  91.         $this->churningActivityLog = new \Doctrine\Common\Collections\ArrayCollection();
  92.     }
  93.     /**
  94.      * __toString.
  95.      */
  96.     public function __toString()
  97.     {
  98.         $newDate = (array)$this->getBookingdate();
  99.         $return $newDate["date"]." - ".$this->getFlightnumber()." - ".$this->getName()." - ".(string)(!is_null($this->getOrder()) ? 'ON'.$this->getOrder()->getId() : 'NA');
  100.         return $return;
  101.     }
  102.     /**
  103.      * Get id.
  104.      *
  105.      * @return int
  106.      */
  107.     public function getId()
  108.     {
  109.         return $this->id;
  110.     }
  111.     /**
  112.      * Set bookingdate.
  113.      *
  114.      * @return Churning
  115.      */
  116.     public function setBookingdate(\DateTime $bookingdate)
  117.     {
  118.         $this->bookingdate $bookingdate;
  119.         return $this;
  120.     }
  121.     /**
  122.      * Get bookingdate.
  123.      *
  124.      * @return \DateTime
  125.      */
  126.     public function getBookingdate()
  127.     {
  128.         return $this->bookingdate;
  129.     }
  130.     /**
  131.      * Set flightdate.
  132.      *
  133.      * @return Churning
  134.      */
  135.     public function setFlightdate(\DateTime $flightdate)
  136.     {
  137.         $this->flightdate $flightdate;
  138.         return $this;
  139.     }
  140.     /**
  141.      * Get flightdate.
  142.      *
  143.      * @return \DateTime|null
  144.      */
  145.     public function getFlightdate()
  146.     {
  147.         return $this->flightdate;
  148.     }
  149.     /**
  150.      * Set departureDate.
  151.      *
  152.      * @return Churning
  153.      */
  154.     public function setDepartureDate(\DateTime $departureDate)
  155.     {
  156.         $this->departureDate $departureDate;
  157.         return $this;
  158.     }
  159.     /**
  160.      * Get departureDate.
  161.      *
  162.      * @return \DateTime|null
  163.      */
  164.     public function getDepartureDate()
  165.     {
  166.         return $this->departureDate;
  167.     }
  168.     /**
  169.      * Set arrivalDate.
  170.      *
  171.      * @return Churning
  172.      */
  173.     public function setArrivalDate(\DateTime $arrivalDate)
  174.     {
  175.         $this->arrivalDate $arrivalDate;
  176.         return $this;
  177.     }
  178.     /**
  179.      * Get arrivalDate.
  180.      *
  181.      * @return \DateTime|null
  182.      */
  183.     public function getArrivalDate()
  184.     {
  185.         return $this->arrivalDate;
  186.     }
  187.     /**
  188.      * Set birthDate.
  189.      *
  190.      * @return Churning
  191.      */
  192.     public function setBirthdate(\DateTime $birthdate null)
  193.     {
  194.         $this->birthdate $birthdate;
  195.         return $this;
  196.     }
  197.     /**
  198.      * Get birthDate.
  199.      *
  200.      * @return \DateTime|null
  201.      */
  202.     public function getBirthdate()
  203.     {
  204.         return $this->birthdate;
  205.     }
  206.     /**
  207.      * Set birthDate.
  208.      *
  209.      * @return Churning
  210.      */
  211.     public function setComment(string $comment null)
  212.     {
  213.         $this->comment $comment;
  214.         return $this;
  215.     }
  216.     /**
  217.      * Get birthDate.
  218.      *
  219.      * @return string
  220.      */
  221.     public function getComment()
  222.     {
  223.         return $this->comment;
  224.     }
  225.     /**
  226.      * Set flightnumber.
  227.      *
  228.      * @param string $flightnumber
  229.      *
  230.      * @return Churning
  231.      */
  232.     public function setFlightnumber($flightnumber)
  233.     {
  234.         $this->flightnumber $flightnumber;
  235.         return $this;
  236.     }
  237.     /**
  238.      * Get flightnumber.
  239.      *
  240.      * @return string
  241.      */
  242.     public function getFlightnumber()
  243.     {
  244.         return $this->flightnumber;
  245.     }
  246.     /**
  247.      * Set document.
  248.      *
  249.      * @param string $document
  250.      *
  251.      * @return Churning
  252.      */
  253.     public function setDocument($document)
  254.     {
  255.         $this->document $document;
  256.         return $this;
  257.     }
  258.     /**
  259.      * Get document.
  260.      *
  261.      * @return string
  262.      */
  263.     public function getDocument()
  264.     {
  265.         return $this->document;
  266.     }
  267.     /**
  268.      * Set name.
  269.      *
  270.      * @param string $name
  271.      *
  272.      * @return Churning
  273.      */
  274.     public function setName($name)
  275.     {
  276.         $this->name $name;
  277.         return $this;
  278.     }
  279.     /**
  280.      * Get name.
  281.      *
  282.      * @return string
  283.      */
  284.     public function getName()
  285.     {
  286.         return $this->name;
  287.     }
  288.     /**
  289.      * Set trynumber.
  290.      *
  291.      * @param string $trynumber
  292.      *
  293.      * @return Churning
  294.      */
  295.     public function setTrynumber($trynumber)
  296.     {
  297.         $this->trynumber $trynumber;
  298.         return $this;
  299.     }
  300.     /**
  301.      * Get trynumber.
  302.      *
  303.      * @return string
  304.      */
  305.     public function getTrynumber()
  306.     {
  307.         return $this->trynumber;
  308.     }
  309.     /**
  310.      * Set enabled.
  311.      *
  312.      * @param string $enabled
  313.      *
  314.      * @return Churning
  315.      */
  316.     public function setEnabled($enabled)
  317.     {
  318.         $this->enabled $enabled;
  319.         return $this;
  320.     }
  321.     /**
  322.      * Get enabled.
  323.      *
  324.      * @return string
  325.      */
  326.     public function getEnabled()
  327.     {
  328.         return $this->enabled;
  329.     }
  330.     
  331.     /**
  332.      * Set order.
  333.      *
  334.      * @param \Aviatur\GeneralBundle\Entity\Order $order
  335.      *
  336.      * @return Churning
  337.      */
  338.     public function setOrder(\Aviatur\GeneralBundle\Entity\Order $order null)
  339.     {
  340.         $this->order $order;
  341.         return $this;
  342.     }
  343.     /**
  344.      * Get order.
  345.      *
  346.      * @return \Aviatur\GeneralBundle\Entity\Order
  347.      */
  348.     public function getOrder()
  349.     {
  350.         return $this->order;
  351.     }
  352.     /**
  353.      * Add churningActivityLog.
  354.      *
  355.      * @return ChurningActivityLog
  356.      */
  357.     public function addChurningActivityLog(\Aviatur\FlightBundle\Entity\ChurningActivityLog $churningActivityLog)
  358.     {
  359.         $this->churningActivityLog[] = $churningActivityLog;
  360.         return $this;
  361.     }
  362.     /**
  363.      * Remove ChurningActivityLog.
  364.      */
  365.     public function removeChurningActivityLog(\Aviatur\FlightBundle\Entity\ChurningActivityLog $churningActivityLog)
  366.     {
  367.         $this->churningActivityLog->removeElement($churningActivityLog);
  368.     }
  369.     /**
  370.      * Get ChurningActivityLog.
  371.      *
  372.      * @return \Doctrine\Common\Collections\Collection
  373.      */
  374.     public function getChurningActivityLog()
  375.     {
  376.         return $this->churningActivityLog;
  377.     }
  378.     /**
  379.      * Get number of booking (Calculated).
  380.      *
  381.      * @return string
  382.      */
  383.     public function getBooking()
  384.     {
  385.         $order $this->getOrder();
  386.         $orderProductList = !is_null($order) ? $order->getOrderProduct() : array();
  387.         $bookingList '';
  388.         $arrayBookings = array();
  389.         foreach ($orderProductList as $orderProduct) {
  390.             if(!is_null($orderProduct->getBooking()) && '' != $orderProduct->getBooking()){
  391.                 if(!in_array($orderProduct->getBooking(), $arrayBookings)){
  392.                     $bookingList = ($bookingList == '' '' ', ').$orderProduct->getBooking();
  393.                     $arrayBookings[] = $orderProduct->getBooking();
  394.                 }
  395.             }
  396.         }
  397.         return $bookingList;
  398.     }
  399. }