src/AppBundle/MainBundle/Entity/PromoCodes.php line 728

Open in your IDE?
  1. <?php
  2. namespace App\AppBundle\MainBundle\Entity;
  3. use DateTime;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JsonSerializable;
  8. use Symfony\Component\Validator\Constraints as Assert;
  9. /**
  10.  * AddOns
  11.  *
  12.  * @ORM\Entity(repositoryClass="App\AppBundle\MainBundle\Repository\PromoCodesRepository")
  13.  * @ORM\Table(name="promo_codes")
  14.  * @ORM\HasLifecycleCallbacks()
  15.  */
  16. class PromoCodes implements JsonSerializable
  17. {
  18.     /**
  19.      * @ORM\Column(type="integer")
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="AUTO")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @var ArrayCollection
  26.      * @ORM\ManyToMany(targetEntity="PS_Add_Spot")
  27.      * @ORM\JoinTable(name="promo_codes_applicable_spots",
  28.      *      joinColumns={@ORM\JoinColumn(name="promo_code_id", referencedColumnName="id")},
  29.      *      inverseJoinColumns={@ORM\JoinColumn(name="add_spot_id", referencedColumnName="id")}
  30.      *      )
  31.      */
  32.     private $add_spots;
  33.     /**
  34.      * @var ArrayCollection
  35.      * @ORM\ManyToMany(targetEntity="User")
  36.      * @ORM\JoinTable(name="promo_codes_applicable_users",
  37.      *      joinColumns={@ORM\JoinColumn(name="promo_code_id", referencedColumnName="id")},
  38.      *      inverseJoinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")}
  39.      *      )
  40.      */
  41.     private $users;
  42.     /**
  43.      * @ORM\Column(type="string", nullable=false)
  44.      */
  45.     private $displayId;
  46.     /**
  47.      * @ORM\Column(type="string", nullable=false)
  48.      */
  49.     private $title;
  50.     /**
  51.      * @ORM\Column(type="string", nullable=true)
  52.      */
  53.     private $description;
  54.     /**
  55.      * @ORM\Column(type="string", nullable=true, length=5000)
  56.      */
  57.     private $terms_conditions;
  58.     /**
  59.      * @ORM\Column(type="string", nullable=true)
  60.      */
  61.     private $image;
  62.     /**
  63.      * @ORM\Column(type="string", nullable=false)
  64.      */
  65.     private $wp_discount_percent '100';
  66.     /**
  67.      * @ORM\Column(type="string", nullable=false)
  68.      */
  69.     private $spot_discount_percent '100';
  70.     /**
  71.      * @ORM\Column(type="integer", nullable=false)
  72.      */
  73.     private $discount_type '0';//General Constant - Discount_Type 0 - By Percent, 1 - By Value
  74.     /**
  75.      * @ORM\Column(type="string", nullable=false)
  76.      */
  77.     private $discount_value '100';
  78.     /**
  79.      * @ORM\ManyToOne(targetEntity="WP_Currency")
  80.      * @ORM\JoinColumn(name="wp_currency_id", referencedColumnName="id")
  81.      */
  82.     private $wp_currency;
  83.     /**
  84.      * @var DateTime
  85.      * @ORM\Column(type="datetime", nullable=true)
  86.      */
  87.     private $start_time;
  88.     /**
  89.      * @var DateTime
  90.      * @ORM\Column(type="datetime", nullable=true)
  91.      */
  92.     private $end_time;
  93.     /**
  94.      * @ORM\Column(type="boolean", nullable=false, options={"default" : 1})
  95.      */
  96.     private $is_applicable_all_time false;
  97.     /**
  98.      * @ORM\Column(type="boolean", nullable=false, options={"default" : 1})
  99.      */
  100.     private $is_applicable_to_all_spot true;
  101.     /**
  102.      * @ORM\Column(type="integer", nullable=false)
  103.      */
  104.     private $user_max_usage 0;
  105.     /**
  106.      * @ORM\Column(type="string", nullable=true)
  107.      */
  108.     private $min_amount_to_apply '0';
  109.     /**
  110.      * @ORM\Column(type="string", nullable=true)
  111.      */
  112.     private $max_discount_possible '0';
  113.     /**
  114.      * @ORM\Column(type="boolean", nullable=false, options={"default" : 1})
  115.      */
  116.     private $is_applicable_to_all_users true;
  117.     /**
  118.      * @ORM\Column(type="boolean", nullable=false, options={"default" : 1})
  119.      */
  120.     private $active true;
  121.     /**
  122.      * @ORM\Column(type="string", nullable=true)
  123.      */
  124.     private $country_code;
  125.     /**
  126.      * @ORM\Column(type="string", nullable=true)
  127.      */
  128.     private $country;
  129.     /**
  130.      * @ORM\Column(type="boolean", nullable=false, options={"default" : 0})
  131.      */
  132.     private $is_banner_promo_code false;
  133.     /**
  134.      * @ORM\Column(type="boolean", nullable=false, options={"default" : 1})
  135.      */
  136.     private $is_applicable_to_all_booking_type true;
  137.     /**
  138.      * @ORM\Column(type="string", nullable=true)
  139.      */
  140.     private $applicable_booking_type;//Based on Booking_Type constant
  141.     /**
  142.      * @var DateTime
  143.      * @ORM\Column(type="datetime", nullable=true)
  144.      */
  145.     private $deactivated_on;
  146.     /**
  147.      * @return mixed
  148.      */
  149.     public function getId()
  150.     {
  151.         return $this->id;
  152.     }
  153.     /**
  154.      * @return ArrayCollection
  155.      */
  156.     public function getAddSpots()
  157.     {
  158.         return $this->add_spots;
  159.     }
  160.     /**
  161.      * @param ArrayCollection $add_spots
  162.      */
  163.     public function setAddSpots($add_spots)
  164.     {
  165.         $this->add_spots $add_spots;
  166.     }
  167.     /**
  168.      * @param PS_Add_Spot $spot
  169.      * @return PromoCodes
  170.      */
  171.     public function addSpot(PS_Add_Spot $spot) {
  172.         if (!$this->add_spots->contains($spot)) {
  173.             $this->add_spots->add($spot);
  174.         }
  175.         return $this;
  176.     }
  177.     /**
  178.      * @param PS_Add_Spot $spot
  179.      */
  180.     public function removeSpot(PS_Add_Spot $spot) {
  181.         $this->add_spots->removeElement($spot);
  182.     }
  183.     /**
  184.      * @return ArrayCollection
  185.      */
  186.     public function getUsers()
  187.     {
  188.         return $this->users;
  189.     }
  190.     /**
  191.      * @param ArrayCollection $users
  192.      */
  193.     public function setUsers($users)
  194.     {
  195.         $this->users $users;
  196.     }
  197.     /**
  198.      * @param User $user
  199.      *
  200.      * @return PromoCodes
  201.      */
  202.     public function addUser(User $user) {
  203.         if (!$this->users->contains($user)) {
  204.             $this->users->add($user);
  205.         }
  206.         return $this;
  207.     }
  208.     /**
  209.      * @param User $user
  210.      */
  211.     public function removeUser(User $user) {
  212.         $this->users->removeElement($user);
  213.     }
  214.     /**
  215.      * @return mixed
  216.      */
  217.     public function getDisplayId()
  218.     {
  219.         return $this->displayId;
  220.     }
  221.     /**
  222.      * @param mixed $displayId
  223.      */
  224.     public function setDisplayId($displayId)
  225.     {
  226.         $this->displayId $displayId;
  227.     }
  228.     /**
  229.      * @return mixed
  230.      */
  231.     public function getTitle()
  232.     {
  233.         return $this->title;
  234.     }
  235.     /**
  236.      * @param mixed $title
  237.      */
  238.     public function setTitle($title)
  239.     {
  240.         $this->title $title;
  241.     }
  242.     /**
  243.      * @return mixed
  244.      */
  245.     public function getDescription()
  246.     {
  247.         return $this->description;
  248.     }
  249.     /**
  250.      * @param mixed $description
  251.      */
  252.     public function setDescription($description)
  253.     {
  254.         $this->description $description;
  255.     }
  256.     /**
  257.      * @return mixed
  258.      */
  259.     public function getImage()
  260.     {
  261.         return $this->image;
  262.     }
  263.     /**
  264.      * @param mixed $image
  265.      */
  266.     public function setImage($image)
  267.     {
  268.         $this->image $image;
  269.     }
  270.     /**
  271.      * @return mixed
  272.      */
  273.     public function getWpDiscountPercent()
  274.     {
  275.         return $this->wp_discount_percent;
  276.     }
  277.     /**
  278.      * @param mixed $wp_discount_percent
  279.      */
  280.     public function setWpDiscountPercent($wp_discount_percent)
  281.     {
  282.         $this->wp_discount_percent $wp_discount_percent;
  283.     }
  284.     /**
  285.      * @return mixed
  286.      */
  287.     public function getSpotDiscountPercent()
  288.     {
  289.         return $this->spot_discount_percent;
  290.     }
  291.     /**
  292.      * @param mixed $spot_discount_percent
  293.      */
  294.     public function setSpotDiscountPercent($spot_discount_percent)
  295.     {
  296.         $this->spot_discount_percent $spot_discount_percent;
  297.     }
  298.     /**
  299.      * @return mixed
  300.      */
  301.     public function getDiscountType()
  302.     {
  303.         return $this->discount_type;
  304.     }
  305.     /**
  306.      * @param mixed $discount_type
  307.      */
  308.     public function setDiscountType($discount_type)
  309.     {
  310.         $this->discount_type $discount_type;
  311.     }
  312.     /**
  313.      * @return mixed
  314.      */
  315.     public function getDiscountValue()
  316.     {
  317.         return $this->discount_value;
  318.     }
  319.     /**
  320.      * @param mixed $discount_value
  321.      */
  322.     public function setDiscountValue($discount_value)
  323.     {
  324.         $this->discount_value $discount_value;
  325.     }
  326.     /**
  327.      * @return DateTime
  328.      */
  329.     public function getStartTime()
  330.     {
  331.         return $this->start_time;
  332.     }
  333.     /**
  334.      * @param DateTime $start_time
  335.      */
  336.     public function setStartTime($start_time)
  337.     {
  338.         $this->start_time $start_time;
  339.     }
  340.     /**
  341.      * @return DateTime
  342.      */
  343.     public function getEndTime()
  344.     {
  345.         return $this->end_time;
  346.     }
  347.     /**
  348.      * @param DateTime $end_time
  349.      */
  350.     public function setEndTime($end_time)
  351.     {
  352.         $this->end_time $end_time;
  353.     }
  354.     /**
  355.      * @return mixed
  356.      */
  357.     public function getIsApplicableToAllSpot()
  358.     {
  359.         return $this->is_applicable_to_all_spot;
  360.     }
  361.     /**
  362.      * @param mixed $is_applicable_to_all_spot
  363.      */
  364.     public function setIsApplicableToAllSpot($is_applicable_to_all_spot)
  365.     {
  366.         $this->is_applicable_to_all_spot $is_applicable_to_all_spot;
  367.     }
  368.     /**
  369.      * @return mixed
  370.      */
  371.     public function getUserMaxUsage()
  372.     {
  373.         return $this->user_max_usage;
  374.     }
  375.     /**
  376.      * @param mixed $user_max_usage
  377.      */
  378.     public function setUserMaxUsage($user_max_usage)
  379.     {
  380.         $this->user_max_usage $user_max_usage;
  381.     }
  382.     /**
  383.      * @return mixed
  384.      */
  385.     public function getMinAmountToApply()
  386.     {
  387.         return $this->min_amount_to_apply;
  388.     }
  389.     /**
  390.      * @param mixed $min_amount_to_apply
  391.      */
  392.     public function setMinAmountToApply($min_amount_to_apply)
  393.     {
  394.         $this->min_amount_to_apply $min_amount_to_apply;
  395.     }
  396.     /**
  397.      * @return mixed
  398.      */
  399.     public function getMaxDiscountPossible()
  400.     {
  401.         return $this->max_discount_possible;
  402.     }
  403.     /**
  404.      * @param mixed $max_discount_possible
  405.      */
  406.     public function setMaxDiscountPossible($max_discount_possible)
  407.     {
  408.         $this->max_discount_possible $max_discount_possible;
  409.     }
  410.     /**
  411.      * @return mixed
  412.      */
  413.     public function getIsApplicableToAllUsers()
  414.     {
  415.         return $this->is_applicable_to_all_users;
  416.     }
  417.     /**
  418.      * @param mixed $is_applicable_to_all_users
  419.      */
  420.     public function setIsApplicableToAllUsers($is_applicable_to_all_users)
  421.     {
  422.         $this->is_applicable_to_all_users $is_applicable_to_all_users;
  423.     }
  424.     /**
  425.      * @return mixed
  426.      */
  427.     public function getActive()
  428.     {
  429.         return $this->active;
  430.     }
  431.     /**
  432.      * @param mixed $active
  433.      */
  434.     public function setActive($active)
  435.     {
  436.         $this->active $active;
  437.     }
  438.     /**
  439.      * @return WP_Currency
  440.      */
  441.     public function getWpCurrency()
  442.     {
  443.         return $this->wp_currency;
  444.     }
  445.     /**
  446.      * @param WP_Currency $wp_currency
  447.      */
  448.     public function setWpCurrency($wp_currency)
  449.     {
  450.         $this->wp_currency $wp_currency;
  451.     }
  452.     /**
  453.      * @return mixed
  454.      */
  455.     public function getCountryCode()
  456.     {
  457.         return $this->country_code;
  458.     }
  459.     /**
  460.      * @param mixed $country_code
  461.      */
  462.     public function setCountryCode($country_code)
  463.     {
  464.         $this->country_code $country_code;
  465.     }
  466.     /**
  467.      * @return mixed
  468.      */
  469.     public function getCountry()
  470.     {
  471.         return $this->country;
  472.     }
  473.     /**
  474.      * @param mixed $country
  475.      */
  476.     public function setCountry($country)
  477.     {
  478.         $this->country $country;
  479.     }
  480.     /**
  481.      * @return mixed
  482.      */
  483.     public function getIsBannerPromoCode()
  484.     {
  485.         return $this->is_banner_promo_code;
  486.     }
  487.     /**
  488.      * @param mixed $is_banner_promo_code
  489.      */
  490.     public function setIsBannerPromoCode($is_banner_promo_code)
  491.     {
  492.         $this->is_banner_promo_code $is_banner_promo_code;
  493.     }
  494.     /**
  495.      * @return mixed
  496.      */
  497.     public function getTermsConditions()
  498.     {
  499.         return $this->terms_conditions;
  500.     }
  501.     /**
  502.      * @param mixed $terms_conditions
  503.      */
  504.     public function setTermsConditions($terms_conditions)
  505.     {
  506.         $this->terms_conditions $terms_conditions;
  507.     }
  508.     /**
  509.      * @return mixed
  510.      */
  511.     public function getIsApplicableAllTime()
  512.     {
  513.         return $this->is_applicable_all_time;
  514.     }
  515.     /**
  516.      * @param mixed $is_applicable_all_time
  517.      */
  518.     public function setIsApplicableAllTime($is_applicable_all_time)
  519.     {
  520.         $this->is_applicable_all_time $is_applicable_all_time;
  521.     }
  522.     /**
  523.      * @return mixed
  524.      */
  525.     public function getIsApplicableToAllBookingType()
  526.     {
  527.         return $this->is_applicable_to_all_booking_type;
  528.     }
  529.     /**
  530.      * @param mixed $is_applicable_to_all_booking_type
  531.      */
  532.     public function setIsApplicableToAllBookingType($is_applicable_to_all_booking_type)
  533.     {
  534.         $this->is_applicable_to_all_booking_type $is_applicable_to_all_booking_type;
  535.     }
  536.     /**
  537.      * @return mixed
  538.      */
  539.     public function getApplicableBookingType()
  540.     {
  541.         return $this->applicable_booking_type;
  542.     }
  543.     /**
  544.      * @param mixed $applicable_booking_type
  545.      */
  546.     public function setApplicableBookingType($applicable_booking_type)
  547.     {
  548.         $this->applicable_booking_type $applicable_booking_type;
  549.     }
  550.     /**
  551.      * @return DateTime
  552.      */
  553.     public function getDeactivatedOn()
  554.     {
  555.         return $this->deactivated_on;
  556.     }
  557.     /**
  558.      * @param DateTime $deactivated_on
  559.      */
  560.     public function setDeactivatedOn($deactivated_on)
  561.     {
  562.         $this->deactivated_on $deactivated_on;
  563.     }
  564.     public function jsonSerialize()
  565.     {
  566.         return array(
  567.             'id' => $this->id,
  568.             'displayId' => $this->displayId,
  569.             'title' => $this->title,
  570.             'description' => $this->description,
  571.             'terms_conditions' => $this->terms_conditions,
  572.             'image' => $this->image,
  573.             'currency_id' => $this->getWpCurrency()->getId(),
  574.             'currency_code' => $this->getWpCurrency()->getCode(),
  575.             'currency_symbol' => $this->getWpCurrency()->getSymbol(),
  576. //            'wp_discount_percent' => $this->wp_discount_percent,
  577. //            'spot_discount_percent' => $this->spot_discount_percent,
  578.             'discount_type' => $this->discount_type,
  579.             'discount_value' => $this->discount_value,
  580.             'start_time' => $this->start_time != NULL $this->start_time->format('Y-m-d H:i:s') : '',
  581.             'end_time' => $this->end_time != NULL $this->end_time->format('Y-m-d H:i:s') : '',
  582. //            'is_applicable_to_all_spot' => $this->is_applicable_to_all_spot,
  583.             'user_max_usage' => $this->user_max_usage,
  584.             'min_amount_to_apply' => $this->min_amount_to_apply,
  585.             'max_discount_possible' => $this->max_discount_possible,
  586.             'is_applicable_all_time' => $this->is_applicable_all_time,
  587. //            'is_applicable_to_all_users' => $this->is_applicable_to_all_users,
  588. //            'country' => $this->country,
  589. //            'country_code' => $this->country_code,
  590. //            'is_banner_promo_code' => $this->is_banner_promo_code,
  591.             'created' => $this->createdAt->format('Y-m-d H:i:s'),
  592.             'updated' => $this->updatedAt->format('Y-m-d H:i:s'),
  593.         );
  594.     }
  595.     /**
  596.      * @var DateTime $created
  597.      *
  598.      * @ORM\Column(type="datetime", nullable=false)
  599.      */
  600.     protected $createdAt;
  601.     /**
  602.      * @var DateTime $updated
  603.      *
  604.      * @ORM\Column(type="datetime", nullable=false)
  605.      */
  606.     protected $updatedAt;
  607.     /**
  608.      * @return DateTime
  609.      */
  610.     public function getCreatedAt()
  611.     {
  612.         return $this->createdAt;
  613.     }
  614.     /**
  615.      * @return DateTime
  616.      */
  617.     public function getUpdatedAt()
  618.     {
  619.         return $this->updatedAt;
  620.     }
  621.     public function setUpdatedAt($updatedAt)
  622.     {
  623.         $this->updatedAt $updatedAt;
  624.         return $this;
  625.     }
  626.     /**
  627.      * @ORM\PrePersist
  628.      */
  629.     public function setCreatedAt()
  630.     {
  631.         $this->createdAt = new DateTime();
  632.         $this->updatedAt = new DateTime();
  633.         return $this;
  634.     }
  635.     /**
  636.      * @ORM\PreUpdate
  637.      */
  638.     public function setUpdatedAtValue() {
  639.         $this->updatedAt = new DateTime();
  640.     }
  641.     public function __construct() {
  642.         $this->add_spots = new ArrayCollection();
  643.         $this->users = new ArrayCollection();
  644.     }
  645. }