<?php
namespace App\AppBundle\MainBundle\Entity;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
use Symfony\Component\Validator\Constraints as Assert;
/**
* AddOns
*
* @ORM\Entity(repositoryClass="App\AppBundle\MainBundle\Repository\PromoCodesRepository")
* @ORM\Table(name="promo_codes")
* @ORM\HasLifecycleCallbacks()
*/
class PromoCodes implements JsonSerializable
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var ArrayCollection
* @ORM\ManyToMany(targetEntity="PS_Add_Spot")
* @ORM\JoinTable(name="promo_codes_applicable_spots",
* joinColumns={@ORM\JoinColumn(name="promo_code_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="add_spot_id", referencedColumnName="id")}
* )
*/
private $add_spots;
/**
* @var ArrayCollection
* @ORM\ManyToMany(targetEntity="User")
* @ORM\JoinTable(name="promo_codes_applicable_users",
* joinColumns={@ORM\JoinColumn(name="promo_code_id", referencedColumnName="id")},
* inverseJoinColumns={@ORM\JoinColumn(name="user_id", referencedColumnName="id")}
* )
*/
private $users;
/**
* @ORM\Column(type="string", nullable=false)
*/
private $displayId;
/**
* @ORM\Column(type="string", nullable=false)
*/
private $title;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $description;
/**
* @ORM\Column(type="string", nullable=true, length=5000)
*/
private $terms_conditions;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $image;
/**
* @ORM\Column(type="string", nullable=false)
*/
private $wp_discount_percent = '100';
/**
* @ORM\Column(type="string", nullable=false)
*/
private $spot_discount_percent = '100';
/**
* @ORM\Column(type="integer", nullable=false)
*/
private $discount_type = '0';//General Constant - Discount_Type 0 - By Percent, 1 - By Value
/**
* @ORM\Column(type="string", nullable=false)
*/
private $discount_value = '100';
/**
* @ORM\ManyToOne(targetEntity="WP_Currency")
* @ORM\JoinColumn(name="wp_currency_id", referencedColumnName="id")
*/
private $wp_currency;
/**
* @var DateTime
* @ORM\Column(type="datetime", nullable=true)
*/
private $start_time;
/**
* @var DateTime
* @ORM\Column(type="datetime", nullable=true)
*/
private $end_time;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" : 1})
*/
private $is_applicable_all_time = false;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" : 1})
*/
private $is_applicable_to_all_spot = true;
/**
* @ORM\Column(type="integer", nullable=false)
*/
private $user_max_usage = 0;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $min_amount_to_apply = '0';
/**
* @ORM\Column(type="string", nullable=true)
*/
private $max_discount_possible = '0';
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" : 1})
*/
private $is_applicable_to_all_users = true;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" : 1})
*/
private $active = true;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $country_code;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $country;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" : 0})
*/
private $is_banner_promo_code = false;
/**
* @ORM\Column(type="boolean", nullable=false, options={"default" : 1})
*/
private $is_applicable_to_all_booking_type = true;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $applicable_booking_type;//Based on Booking_Type constant
/**
* @var DateTime
* @ORM\Column(type="datetime", nullable=true)
*/
private $deactivated_on;
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return ArrayCollection
*/
public function getAddSpots()
{
return $this->add_spots;
}
/**
* @param ArrayCollection $add_spots
*/
public function setAddSpots($add_spots)
{
$this->add_spots = $add_spots;
}
/**
* @param PS_Add_Spot $spot
* @return PromoCodes
*/
public function addSpot(PS_Add_Spot $spot) {
if (!$this->add_spots->contains($spot)) {
$this->add_spots->add($spot);
}
return $this;
}
/**
* @param PS_Add_Spot $spot
*/
public function removeSpot(PS_Add_Spot $spot) {
$this->add_spots->removeElement($spot);
}
/**
* @return ArrayCollection
*/
public function getUsers()
{
return $this->users;
}
/**
* @param ArrayCollection $users
*/
public function setUsers($users)
{
$this->users = $users;
}
/**
* @param User $user
*
* @return PromoCodes
*/
public function addUser(User $user) {
if (!$this->users->contains($user)) {
$this->users->add($user);
}
return $this;
}
/**
* @param User $user
*/
public function removeUser(User $user) {
$this->users->removeElement($user);
}
/**
* @return mixed
*/
public function getDisplayId()
{
return $this->displayId;
}
/**
* @param mixed $displayId
*/
public function setDisplayId($displayId)
{
$this->displayId = $displayId;
}
/**
* @return mixed
*/
public function getTitle()
{
return $this->title;
}
/**
* @param mixed $title
*/
public function setTitle($title)
{
$this->title = $title;
}
/**
* @return mixed
*/
public function getDescription()
{
return $this->description;
}
/**
* @param mixed $description
*/
public function setDescription($description)
{
$this->description = $description;
}
/**
* @return mixed
*/
public function getImage()
{
return $this->image;
}
/**
* @param mixed $image
*/
public function setImage($image)
{
$this->image = $image;
}
/**
* @return mixed
*/
public function getWpDiscountPercent()
{
return $this->wp_discount_percent;
}
/**
* @param mixed $wp_discount_percent
*/
public function setWpDiscountPercent($wp_discount_percent)
{
$this->wp_discount_percent = $wp_discount_percent;
}
/**
* @return mixed
*/
public function getSpotDiscountPercent()
{
return $this->spot_discount_percent;
}
/**
* @param mixed $spot_discount_percent
*/
public function setSpotDiscountPercent($spot_discount_percent)
{
$this->spot_discount_percent = $spot_discount_percent;
}
/**
* @return mixed
*/
public function getDiscountType()
{
return $this->discount_type;
}
/**
* @param mixed $discount_type
*/
public function setDiscountType($discount_type)
{
$this->discount_type = $discount_type;
}
/**
* @return mixed
*/
public function getDiscountValue()
{
return $this->discount_value;
}
/**
* @param mixed $discount_value
*/
public function setDiscountValue($discount_value)
{
$this->discount_value = $discount_value;
}
/**
* @return DateTime
*/
public function getStartTime()
{
return $this->start_time;
}
/**
* @param DateTime $start_time
*/
public function setStartTime($start_time)
{
$this->start_time = $start_time;
}
/**
* @return DateTime
*/
public function getEndTime()
{
return $this->end_time;
}
/**
* @param DateTime $end_time
*/
public function setEndTime($end_time)
{
$this->end_time = $end_time;
}
/**
* @return mixed
*/
public function getIsApplicableToAllSpot()
{
return $this->is_applicable_to_all_spot;
}
/**
* @param mixed $is_applicable_to_all_spot
*/
public function setIsApplicableToAllSpot($is_applicable_to_all_spot)
{
$this->is_applicable_to_all_spot = $is_applicable_to_all_spot;
}
/**
* @return mixed
*/
public function getUserMaxUsage()
{
return $this->user_max_usage;
}
/**
* @param mixed $user_max_usage
*/
public function setUserMaxUsage($user_max_usage)
{
$this->user_max_usage = $user_max_usage;
}
/**
* @return mixed
*/
public function getMinAmountToApply()
{
return $this->min_amount_to_apply;
}
/**
* @param mixed $min_amount_to_apply
*/
public function setMinAmountToApply($min_amount_to_apply)
{
$this->min_amount_to_apply = $min_amount_to_apply;
}
/**
* @return mixed
*/
public function getMaxDiscountPossible()
{
return $this->max_discount_possible;
}
/**
* @param mixed $max_discount_possible
*/
public function setMaxDiscountPossible($max_discount_possible)
{
$this->max_discount_possible = $max_discount_possible;
}
/**
* @return mixed
*/
public function getIsApplicableToAllUsers()
{
return $this->is_applicable_to_all_users;
}
/**
* @param mixed $is_applicable_to_all_users
*/
public function setIsApplicableToAllUsers($is_applicable_to_all_users)
{
$this->is_applicable_to_all_users = $is_applicable_to_all_users;
}
/**
* @return mixed
*/
public function getActive()
{
return $this->active;
}
/**
* @param mixed $active
*/
public function setActive($active)
{
$this->active = $active;
}
/**
* @return WP_Currency
*/
public function getWpCurrency()
{
return $this->wp_currency;
}
/**
* @param WP_Currency $wp_currency
*/
public function setWpCurrency($wp_currency)
{
$this->wp_currency = $wp_currency;
}
/**
* @return mixed
*/
public function getCountryCode()
{
return $this->country_code;
}
/**
* @param mixed $country_code
*/
public function setCountryCode($country_code)
{
$this->country_code = $country_code;
}
/**
* @return mixed
*/
public function getCountry()
{
return $this->country;
}
/**
* @param mixed $country
*/
public function setCountry($country)
{
$this->country = $country;
}
/**
* @return mixed
*/
public function getIsBannerPromoCode()
{
return $this->is_banner_promo_code;
}
/**
* @param mixed $is_banner_promo_code
*/
public function setIsBannerPromoCode($is_banner_promo_code)
{
$this->is_banner_promo_code = $is_banner_promo_code;
}
/**
* @return mixed
*/
public function getTermsConditions()
{
return $this->terms_conditions;
}
/**
* @param mixed $terms_conditions
*/
public function setTermsConditions($terms_conditions)
{
$this->terms_conditions = $terms_conditions;
}
/**
* @return mixed
*/
public function getIsApplicableAllTime()
{
return $this->is_applicable_all_time;
}
/**
* @param mixed $is_applicable_all_time
*/
public function setIsApplicableAllTime($is_applicable_all_time)
{
$this->is_applicable_all_time = $is_applicable_all_time;
}
/**
* @return mixed
*/
public function getIsApplicableToAllBookingType()
{
return $this->is_applicable_to_all_booking_type;
}
/**
* @param mixed $is_applicable_to_all_booking_type
*/
public function setIsApplicableToAllBookingType($is_applicable_to_all_booking_type)
{
$this->is_applicable_to_all_booking_type = $is_applicable_to_all_booking_type;
}
/**
* @return mixed
*/
public function getApplicableBookingType()
{
return $this->applicable_booking_type;
}
/**
* @param mixed $applicable_booking_type
*/
public function setApplicableBookingType($applicable_booking_type)
{
$this->applicable_booking_type = $applicable_booking_type;
}
/**
* @return DateTime
*/
public function getDeactivatedOn()
{
return $this->deactivated_on;
}
/**
* @param DateTime $deactivated_on
*/
public function setDeactivatedOn($deactivated_on)
{
$this->deactivated_on = $deactivated_on;
}
public function jsonSerialize()
{
return array(
'id' => $this->id,
'displayId' => $this->displayId,
'title' => $this->title,
'description' => $this->description,
'terms_conditions' => $this->terms_conditions,
'image' => $this->image,
'currency_id' => $this->getWpCurrency()->getId(),
'currency_code' => $this->getWpCurrency()->getCode(),
'currency_symbol' => $this->getWpCurrency()->getSymbol(),
// 'wp_discount_percent' => $this->wp_discount_percent,
// 'spot_discount_percent' => $this->spot_discount_percent,
'discount_type' => $this->discount_type,
'discount_value' => $this->discount_value,
'start_time' => $this->start_time != NULL ? $this->start_time->format('Y-m-d H:i:s') : '',
'end_time' => $this->end_time != NULL ? $this->end_time->format('Y-m-d H:i:s') : '',
// 'is_applicable_to_all_spot' => $this->is_applicable_to_all_spot,
'user_max_usage' => $this->user_max_usage,
'min_amount_to_apply' => $this->min_amount_to_apply,
'max_discount_possible' => $this->max_discount_possible,
'is_applicable_all_time' => $this->is_applicable_all_time,
// 'is_applicable_to_all_users' => $this->is_applicable_to_all_users,
// 'country' => $this->country,
// 'country_code' => $this->country_code,
// 'is_banner_promo_code' => $this->is_banner_promo_code,
'created' => $this->createdAt->format('Y-m-d H:i:s'),
'updated' => $this->updatedAt->format('Y-m-d H:i:s'),
);
}
/**
* @var DateTime $created
*
* @ORM\Column(type="datetime", nullable=false)
*/
protected $createdAt;
/**
* @var DateTime $updated
*
* @ORM\Column(type="datetime", nullable=false)
*/
protected $updatedAt;
/**
* @return DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* @return DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* @ORM\PrePersist
*/
public function setCreatedAt()
{
$this->createdAt = new DateTime();
$this->updatedAt = new DateTime();
return $this;
}
/**
* @ORM\PreUpdate
*/
public function setUpdatedAtValue() {
$this->updatedAt = new DateTime();
}
public function __construct() {
$this->add_spots = new ArrayCollection();
$this->users = new ArrayCollection();
}
}