sterntours/trunk/src/AppBundle/Entity/FewoLodging.php
valentin.wacker ab026b752f #1352
DB-Skript:

CREATE TABLE fewo_lodging (id INT AUTO_INCREMENT NOT NULL, type_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, description LONGTEXT NOT NULL, equipment LONGTEXT NOT NULL, adress1 VARCHAR(255) NOT NULL, adress2 VARCHAR(255) DEFAULT NULL, zip_code VARCHAR(255) NOT NULL, city VARCHAR(255) NOT NULL, maximum_persons INT NOT NULL, deposit DOUBLE PRECISION NOT NULL, only_weekday INT NOT NULL, calendar_visible TINYINT(1) NOT NULL, INDEX IDX_9629C357C54C8C93 (type_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE fewo_lodging_image (id INT AUTO_INCREMENT NOT NULL, lodging_id INT DEFAULT NULL, full_file_name VARCHAR(255) NOT NULL, file_name VARCHAR(255) NOT NULL, description VARCHAR(255) DEFAULT NULL, INDEX IDX_D49F667187335AF1 (lodging_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE fewo_lodging_type (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE fewo_price (id INT AUTO_INCREMENT NOT NULL, lodging_id INT DEFAULT NULL, season_id INT DEFAULT NULL, per_night DOUBLE PRECISION NOT NULL, flat_price DOUBLE PRECISION NOT NULL, INDEX IDX_3DE13C987335AF1 (lodging_id), INDEX IDX_3DE13C94EC001D1 (season_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE fewo_reservation (id INT AUTO_INCREMENT NOT NULL, lodging_id INT DEFAULT NULL, from_date DATE NOT NULL, to_date DATE NOT NULL, status INT NOT NULL, type INT NOT NULL, INDEX IDX_36537F7487335AF1 (lodging_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
CREATE TABLE fewo_season (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, from_date DATE NOT NULL, to_date DATE NOT NULL, minimum_stay INT NOT NULL, description LONGTEXT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
ALTER TABLE fewo_lodging ADD CONSTRAINT FK_9629C357C54C8C93 FOREIGN KEY (type_id) REFERENCES fewo_lodging_type (id);
ALTER TABLE fewo_lodging_image ADD CONSTRAINT FK_D49F667187335AF1 FOREIGN KEY (lodging_id) REFERENCES fewo_lodging (id) ON DELETE SET NULL;
ALTER TABLE fewo_price ADD CONSTRAINT FK_3DE13C987335AF1 FOREIGN KEY (lodging_id) REFERENCES fewo_lodging (id);
ALTER TABLE fewo_price ADD CONSTRAINT FK_3DE13C94EC001D1 FOREIGN KEY (season_id) REFERENCES fewo_season (id) ON DELETE SET NULL;
ALTER TABLE fewo_reservation ADD CONSTRAINT FK_36537F7487335AF1 FOREIGN KEY (lodging_id) REFERENCES fewo_lodging (id) ON DELETE SET NULL;
ALTER TABLE page ADD fewo_lodging INT DEFAULT NULL;
ALTER TABLE page ADD CONSTRAINT FK_140AB6209629C357 FOREIGN KEY (fewo_lodging) REFERENCES fewo_lodging (id) ON DELETE SET NULL;
CREATE UNIQUE INDEX UNIQ_140AB6209629C357 ON page (fewo_lodging);

INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Apartment');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Bauernhof');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Bungalow');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Campingplatz');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Chalet');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Ferienanlage');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Ferienhaus');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Ferienwohnung');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Finca');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Hotel');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Hütte');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Pension');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Schloss');
INSERT INTO `fewo_lodging_type` (`name`) VALUES ('Villa');

git-svn-id: http://78.47.251.156/svn/dev/sterntours-3@3348 f459cee4-fb09-11de-96c3-f9c5f16c3c76
2017-10-25 12:25:37 +00:00

619 lines
11 KiB
PHP

<?php
namespace AppBundle\Entity;
use AppBundle\AppBundle;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table
* @ORM\Entity(repositoryClass="AppBundle\Entity\FewoLodgingRepository")
*/
class FewoLodging
{
//------------------------------------------------------------------------------------------------------------------
// Allgemein
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
*/
private $name;
/**
* @var \AppBundle\Entity\FewoLodgingType
*
* @ORM\ManyToOne(targetEntity="FewoLodgingType")
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="type_id", referencedColumnName="id")
* })
*/
private $type;
/**
* @var text
*
* @ORM\Column(name="description", type="text", nullable=false)
*/
private $description;
/**
* @var text
*
* @ORM\Column(name="equipment", type="text", nullable=false)
*/
private $equipment;
//------------------------------------------------------------------------------------------------------------------
// Adresse
/**
* @var string
*
* @ORM\Column(name="adress1", type="string", length=255, nullable=false)
*/
private $adress1;
/**
* @var string
*
* @ORM\Column(name="adress2", type="string", length=255, nullable=true)
*/
private $adress2;
/**
* @var string
*
* @ORM\Column(name="zip_code", type="string", length=255, nullable=false)
*/
private $zipCode;
/**
* @var string
*
* @ORM\Column(name="city", type="string", length=255, nullable=false)
*/
private $city;
//------------------------------------------------------------------------------------------------------------------
// Preise
/**
* @var integer
*
* @ORM\Column(name="maximum_persons", type="integer", nullable=false)
*/
private $maximumPersons;
/**
* @var float
*
* @ORM\Column(name="deposit", type="float", scale=2, nullable=false)
*/
private $deposit;
/**
* @var \AppBundle\Entity\FewoPrice
*
* @ORM\OneToMany(targetEntity="FewoPrice", mappedBy="lodging", cascade={"persist", "remove"})
*/
private $prices;
//------------------------------------------------------------------------------------------------------------------
// Bilder
/**
* @ORM\OneToMany(targetEntity="FewoLodgingImage", mappedBy="lodging", cascade={"persist", "remove"})
*/
private $images;
//------------------------------------------------------------------------------------------------------------------
// Kalender
/**
* @var integer
*
* @ORM\Column(name="only_weekday", type="integer", nullable=false)
*/
private $onlyWeekday;
/**
* @var \AppBundle\Entity\FewoReservation
*
* @ORM\OneToMany(targetEntity="FewoReservation", mappedBy="lodging", cascade={"persist", "remove"})
*/
private $reservations;
/**
* @var boolean
*
* @ORM\Column(name="calendar_visible", type="boolean", nullable=false)
*/
private $calendarVisible;
private $choosableSeasons;
/**
* @ORM\OneToOne(targetEntity="AppBundle\Entity\Page", mappedBy="fewoLodging")
*/
private $page;
public function getChoosableSeasons()
{
return $this->choosableSeasons;
}
public function setChoosableSeasons($choosableSeasons)
{
$this->choosableSeasons = $choosableSeasons;
}
public function getSeasons()
{
$prices = $this->getPrices();
$seasons = null;
for($i = 0; $i < count($prices); $i++)
{
$seasons[] = $prices->get($i)->getSeason();
}
return $seasons;
}
/**
* Constructor
*/
public function __construct()
{
$this->prices = new \Doctrine\Common\Collections\ArrayCollection();
$this->images = new \Doctrine\Common\Collections\ArrayCollection();
$this->reservations = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
*
* @return FewoLodging
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set description
*
* @param string $description
*
* @return FewoLodging
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Set equipment
*
* @param string $equipment
*
* @return FewoLodging
*/
public function setEquipment($equipment)
{
$this->equipment = $equipment;
return $this;
}
/**
* Get equipment
*
* @return string
*/
public function getEquipment()
{
return $this->equipment;
}
/**
* Set adress1
*
* @param string $adress1
*
* @return FewoLodging
*/
public function setAdress1($adress1)
{
$this->adress1 = $adress1;
return $this;
}
/**
* Get adress1
*
* @return string
*/
public function getAdress1()
{
return $this->adress1;
}
/**
* Set adress2
*
* @param string $adress2
*
* @return FewoLodging
*/
public function setAdress2($adress2)
{
$this->adress2 = $adress2;
return $this;
}
/**
* Get adress2
*
* @return string
*/
public function getAdress2()
{
return $this->adress2;
}
/**
* Set zipCode
*
* @param string $zipCode
*
* @return FewoLodging
*/
public function setZipCode($zipCode)
{
$this->zipCode = $zipCode;
return $this;
}
/**
* Get zipCode
*
* @return string
*/
public function getZipCode()
{
return $this->zipCode;
}
/**
* Set city
*
* @param string $city
*
* @return FewoLodging
*/
public function setCity($city)
{
$this->city = $city;
return $this;
}
/**
* Get city
*
* @return string
*/
public function getCity()
{
return $this->city;
}
/**
* Set maximumPersons
*
* @param integer $maximumPersons
*
* @return FewoLodging
*/
public function setMaximumPersons($maximumPersons)
{
$this->maximumPersons = $maximumPersons;
return $this;
}
/**
* Get maximumPersons
*
* @return integer
*/
public function getMaximumPersons()
{
return $this->maximumPersons;
}
/**
* Set deposit
*
* @param float $deposit
*
* @return FewoLodging
*/
public function setDeposit($deposit)
{
$this->deposit = $deposit;
return $this;
}
/**
* Get deposit
*
* @return float
*/
public function getDeposit()
{
return $this->deposit;
}
/**
* Set onlyWeekday
*
* @param integer $onlyWeekday
*
* @return FewoLodging
*/
public function setOnlyWeekday($onlyWeekday)
{
$this->onlyWeekday = $onlyWeekday;
return $this;
}
/**
* Get onlyWeekday
*
* @return integer
*/
public function getOnlyWeekday()
{
return $this->onlyWeekday;
}
/**
* Set calendarVisible
*
* @param boolean $calendarVisible
*
* @return FewoLodging
*/
public function setCalendarVisible($calendarVisible)
{
$this->calendarVisible = $calendarVisible;
return $this;
}
/**
* Get calendarVisible
*
* @return boolean
*/
public function getCalendarVisible()
{
return $this->calendarVisible;
}
/**
* Set type
*
* @param \AppBundle\Entity\FewoLodgingType $type
*
* @return FewoLodging
*/
public function setType(\AppBundle\Entity\FewoLodgingType $type = null)
{
$this->type = $type;
return $this;
}
/**
* Get type
*
* @return \AppBundle\Entity\FewoLodgingType
*/
public function getType()
{
return $this->type;
}
/**
* Add price
*
* @param \AppBundle\Entity\FewoPrice $price
*
* @return FewoLodging
*/
public function addPrice(\AppBundle\Entity\FewoPrice $price)
{
$this->prices[] = $price;
return $this;
}
/**
* Remove price
*
* @param \AppBundle\Entity\FewoPrice $price
*/
public function removePrice(\AppBundle\Entity\FewoPrice $price)
{
$this->prices->removeElement($price);
}
/**
* Get prices
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getPrices()
{
return $this->prices;
}
/**
* Add image
*
* @param \AppBundle\Entity\FewoLodgingImage $image
*
* @return FewoLodging
*/
public function addImage(\AppBundle\Entity\FewoLodgingImage $image)
{
$this->images[] = $image;
return $this;
}
/**
* Remove image
*
* @param \AppBundle\Entity\FewoLodgingImage $image
*/
public function removeImage(\AppBundle\Entity\FewoLodgingImage $image)
{
$this->images->removeElement($image);
}
/**
* Get images
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getImages()
{
return $this->images;
}
/**
* Add reservation
*
* @param \AppBundle\Entity\FewoReservation $reservation
*
* @return FewoLodging
*/
public function addReservation(\AppBundle\Entity\FewoReservation $reservation)
{
$this->reservations[] = $reservation;
return $this;
}
/**
* Remove reservation
*
* @param \AppBundle\Entity\FewoReservation $reservation
*/
public function removeReservation(\AppBundle\Entity\FewoReservation $reservation)
{
$this->reservations->removeElement($reservation);
}
/**
* Get reservations
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getReservations()
{
return $this->reservations;
}
/**
* Set page
*
* @param \AppBundle\Entity\Page $page
*
* @return FewoLodging
*/
public function setPage(\AppBundle\Entity\Page $page = null)
{
$this->page = $page;
return $this;
}
/**
* Get page
*
* @return \AppBundle\Entity\Page
*/
public function getPage()
{
return $this->page;
}
function __toString()
{
return $this->name;
}
}