<?phpnamespace CoreBundle\Entity\Vehicles;use Doctrine\Common\Collections\ArrayCollection;use Application\Sonata\MediaBundle\Entity\Media;use Application\Sonata\MediaBundle\Entity\Gallery;use Doctrine\Common\Collections\Collection;use DateTime;/** * InStock */class InStock{ /** * @var integer */ private $id; /** * @var integer */ private $temp_id; /** * @var string */ private $url; /** * @var integer */ private $state; /** * @var integer */ private $add_cost; /** * @var integer */ private $action_price; /** * @var integer */ private $price_usd; /** * @var integer */ private $action_price_usd; /** * @var string */ private $color; /** * @var string */ private $vin; /** * @var Media */ private $preview; /** * @var Gallery */ private $gallery; /** * @var Gallery */ private $video; /** * @var Collection */ private $content; /** * @var VehicleItem */ private $vehicle_item; /** * @var VehicleCardType|null */ private $vehicleCardType; private DateTime $updatedAt; /** * Constructor */ public function __construct() { $this->content = new ArrayCollection(); $this->content->add((new InStockContent())->setLanguage('ru')->setVehicle($this)); $this->content->add((new InStockContent())->setLanguage('ua')->setVehicle($this)); } /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set tempId * * @param integer $tempId * * @return InStock */ public function setTempId($tempId) { $this->temp_id = $tempId; return $this; } /** * Get tempId * * @return integer */ public function getTempId() { return $this->temp_id; } /** * Set url * * @param string $url * * @return InStock */ public function setUrl($url) { $this->url = $url; return $this; } /** * Get url * * @return string */ public function getUrl() { return $this->url; } /** * Set state * * @param integer $state * * @return InStock */ public function setState($state) { $this->state = $state; return $this; } /** * Get state * * @return integer */ public function getState() { return $this->state > 0; } /** * Set addCost * * @param integer $addCost * * @return InStock */ public function setAddCost($addCost) { $this->add_cost = $addCost; return $this; } /** * Get addCost * * @return integer */ public function getAddCost() { return $this->add_cost; } /** * Set actionPrice * * @param integer $actionPrice * * @return InStock */ public function setActionPrice($actionPrice) { $this->action_price = $actionPrice; return $this; } /** * Get actionPrice * * @return integer */ public function getActionPrice() { return $this->action_price; } /** * Set priceUsd * * @param integer $priceUsd * * @return InStock */ public function setPriceUsd($priceUsd) { $this->price_usd = $priceUsd; return $this; } /** * Get priceUsd * * @return integer */ public function getPriceUsd() { return $this->price_usd; } /** * Set actionPriceUsd * * @param integer $actionPriceUsd * * @return InStock */ public function setActionPriceUsd($actionPriceUsd) { $this->action_price_usd = $actionPriceUsd; return $this; } /** * Get actionPriceUsd * * @return integer */ public function getActionPriceUsd() { return $this->action_price_usd; } /** * Set color * * @param string $color * * @return InStock */ public function setColor($color) { $this->color = $color; return $this; } /** * Get color * * @return string */ public function getColor() { return $this->color; } /** * Set vin * * @param string $vin * * @return InStock */ public function setVin($vin) { $this->vin = $vin; return $this; } /** * Get vin * * @return string */ public function getVin() { return $this->vin; } /** * Set preview * * @param Media $preview * * @return InStock */ public function setPreview(Media $preview = null) { $this->preview = $preview; return $this; } /** * Get preview * * @return Media */ public function getPreview() { return $this->preview; } /** * Set gallery * * @param Gallery $gallery * * @return InStock */ public function setGallery(Gallery $gallery = null) { $this->gallery = $gallery; return $this; } /** * Get gallery * * @return Gallery */ public function getGallery() { return $this->gallery; } /** * Set video * * @param Gallery $video * * @return InStock */ public function setVideo(Gallery $video = null) { $this->video = $video; return $this; } /** * Get video * * @return Gallery */ public function getVideo() { return $this->video; } /** * Add content * * @param InStockContent $content * * @return InStock */ public function addContent(InStockContent $content) { $this->content[] = $content; return $this; } /** * Remove content * * @param InStockContent $content */ public function removeContent(InStockContent $content) { $this->content->removeElement($content); } /** * Get content * * @return Collection */ public function getContent() { return $this->content; } public function getContentByLocale($locale) { /** @var InStockContent $iContent */ foreach ($this->content as $iContent) { if($iContent->getLanguage() == $locale) { return $iContent; } } return $this->content->first(); } /** * Set vehicleItem * * @param VehicleItem $vehicleItem * * @return InStock */ public function setVehicleItem(VehicleItem $vehicleItem = null) { $this->vehicle_item = $vehicleItem; return $this; } /** * Get vehicleItem * * @return VehicleItem */ public function getVehicleItem() { return $this->vehicle_item; } public function calcPrice() { if($this->action_price) { return $this->action_price; } if($this->action_price_usd) { $rate = $this->getVehicleItem()->getVariation()->getVehicle()->getDealer()->getRate(); return round($this->action_price_usd * $rate); } if($this->price_usd) { $rate = $this->getVehicleItem()->getVariation()->getVehicle()->getDealer()->getRate(); return round($this->price_usd * $rate); } return round($this->getVehicleItem()->calcPrice() + $this->add_cost); } public function formatedPrice(): string { return number_format($this->calcPrice(),0,'.',' '); } /** * @var string */ private $is_delete = 0; /** * Set isDelete * * @param string $isDelete * * @return InStock */ public function setIsDelete($isDelete) { $this->is_delete = $isDelete; return $this; } /** * Get isDelete * * @return string */ public function getIsDelete() { return $this->is_delete; } public function __toString() { $VehicleItem = $this->getVehicleItem(); if(!$VehicleItem) { return ''; } $Name = (string) $VehicleItem->getVehicle()->getModel(); if($VehicleItem->getSpecification()) { $Name .= ' '.$VehicleItem->getSpecification()->getTitleRu(); } $Name .= ' '.$this->getColor(); return $Name; } /** * @var integer */ private $in_delivery = 0; /** * Set inDelivery * * @param integer $inDelivery * * @return InStock */ public function setInDelivery($inDelivery) { $this->in_delivery = $inDelivery; return $this; } /** * Get inDelivery * * @return integer */ public function getInDelivery() { return $this->in_delivery > 0; } /** * @var ConfiguratorColor */ private $color_item; /** * Set colorItem * * @param ConfiguratorColor $colorItem * * @return InStock */ public function setColorItem(ConfiguratorColor $colorItem = null) { $this->color_item = $colorItem; return $this; } /** * Get colorItem * * @return ConfiguratorColor */ public function getColorItem() { return $this->color_item; } /** * @var integer */ private $mileage; /** * Set mileage * * @param integer $mileage * * @return InStock */ public function setMileage($mileage) { $this->mileage = $mileage; return $this; } /** * Get mileage * * @return integer */ public function getMileage() { return $this->mileage; } /** * @var Collection */ private $parts; /** * Add part * * @param InStockPart $part * * @return InStock */ public function addPart(InStockPart $part) { $this->parts[] = $part; return $this; } /** * Remove part * * @param InStockPart $part */ public function removePart(InStockPart $part) { $this->parts->removeElement($part); } /** * Get parts * * @return Collection */ public function getParts() { return $this->parts; } /** * @var boolean */ private $in_storage = 0; /** * @var boolean */ private $is_reserved = 0; /** * Set inStorage * * @param boolean $inStorage * * @return InStock */ public function setInStorage($inStorage) { $this->in_storage = $inStorage; return $this; } /** * Get inStorage * * @return boolean */ public function getInStorage() { return (boolean)$this->in_storage; } /** * Set isReserved * * @param boolean $isReserved * * @return InStock */ public function setIsReserved($isReserved) { $this->is_reserved = $isReserved; return $this; } /** * Get isReserved * * @return boolean */ public function getIsReserved() { return (boolean)$this->is_reserved; } /** * @var boolean */ private $specify_price = 0; /** * Set specifyPrice * * @param boolean $specifyPrice * * @return InStock */ public function setSpecifyPrice($specifyPrice) { $this->specify_price = $specifyPrice; return $this; } /** * Get specifyPrice * * @return boolean */ public function getSpecifyPrice() { return (boolean) $this->specify_price; } /** * @var integer */ private $delivery_term = 0; /** * Set deliveryTerm * * @param integer $deliveryTerm * * @return InStock */ public function setDeliveryTerm($deliveryTerm) { $this->delivery_term = $deliveryTerm; return $this; } /** * Get deliveryTerm * * @return integer */ public function getDeliveryTerm() { return $this->delivery_term; } /** * @var Media */ private $preview_second; /** * Set previewSecond * * @param Media $previewSecond * * @return InStock */ public function setPreviewSecond(Media $previewSecond = null) { $this->preview_second = $previewSecond; return $this; } /** * Get previewSecond * * @return Media */ public function getPreviewSecond() { return $this->preview_second; } /** * @var bool */ private $to_order = 0; /** * Set toOrder. * * @param bool $toOrder * * @return InStock */ public function setToOrder($toOrder) { $this->to_order = $toOrder; return $this; } /** * Get toOrder. * * @return boolean */ public function getToOrder() { return (boolean) $this->to_order; } public function setVehicleCardType(?VehicleCardType $vehicleCardType): InStock { $this->vehicleCardType = $vehicleCardType; if ($vehicleCardType !== null) { $vehicleCardType->setInStockVehicle($this); } return $this; } public function getVehicleCardType(): ?VehicleCardType { return $this->vehicleCardType; } /** * @var bool */ private $e_power = 0; /** * Set ePower. * * @param bool $ePower * * @return InStock */ public function setEPower($ePower) { $this->e_power = $ePower; return $this; } /** * Get ePower. * * @return bool */ public function getEPower() { return (boolean) $this->e_power; } /** * @var DateTime */ private $date_create; /** * Set dateCreate. * * @param DateTime $dateCreate * * @return InStock */ public function setDateCreate($dateCreate) { $this->date_create = $dateCreate; return $this; } /** * Get dateCreate. * * @return DateTime */ public function getDateCreate() { return $this->date_create; } /** * @var bool */ private $page_main = 0; /** * Set pageMain. * * @param bool $pageMain * * @return InStock */ public function setPageMain($pageMain) { $this->page_main = $pageMain; return $this; } /** * Get pageMain. * * @return bool */ public function getPageMain() { return (boolean) $this->page_main; } public function getUpdatedAt(): DateTime { return $this->updatedAt; } public function setUpdatedAt(): self { $this->updatedAt = new \DateTime(); return $this; }}