src/CoreBundle/Entity/Vehicles/InStock.php line 14

Open in your IDE?
  1. <?php
  2. namespace CoreBundle\Entity\Vehicles;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Application\Sonata\MediaBundle\Entity\Media;
  5. use Application\Sonata\MediaBundle\Entity\Gallery;
  6. use Doctrine\Common\Collections\Collection;
  7. use DateTime;
  8. /**
  9.  * InStock
  10.  */
  11. class InStock
  12. {
  13.     /**
  14.      * @var integer
  15.      */
  16.     private $id;
  17.     /**
  18.      * @var integer
  19.      */
  20.     private $temp_id;
  21.     /**
  22.      * @var string
  23.      */
  24.     private $url;
  25.     /**
  26.      * @var integer
  27.      */
  28.     private $state;
  29.     /**
  30.      * @var integer
  31.      */
  32.     private $add_cost;
  33.     /**
  34.      * @var integer
  35.      */
  36.     private $action_price;
  37.     /**
  38.      * @var integer
  39.      */
  40.     private $price_usd;
  41.     /**
  42.      * @var integer
  43.      */
  44.     private $action_price_usd;
  45.     /**
  46.      * @var string
  47.      */
  48.     private $color;
  49.     /**
  50.      * @var string
  51.      */
  52.     private $vin;
  53.     /**
  54.      * @var Media
  55.      */
  56.     private $preview;
  57.     /**
  58.      * @var Gallery
  59.      */
  60.     private $gallery;
  61.     /**
  62.      * @var Gallery
  63.      */
  64.     private $video;
  65.     /**
  66.      * @var Collection
  67.      */
  68.     private $content;
  69.     /**
  70.      * @var VehicleItem
  71.      */
  72.     private $vehicle_item;
  73.     /**
  74.      * @var VehicleCardType|null
  75.      */
  76.     private $vehicleCardType;
  77.     private DateTime $updatedAt;
  78.     /**
  79.      * Constructor
  80.      */
  81.     public function __construct()
  82.     {
  83.         $this->content = new ArrayCollection();
  84.         $this->content->add((new InStockContent())->setLanguage('ru')->setVehicle($this));
  85.         $this->content->add((new InStockContent())->setLanguage('ua')->setVehicle($this));
  86.     }
  87.     /**
  88.      * Get id
  89.      *
  90.      * @return integer
  91.      */
  92.     public function getId()
  93.     {
  94.         return $this->id;
  95.     }
  96.     /**
  97.      * Set tempId
  98.      *
  99.      * @param integer $tempId
  100.      *
  101.      * @return InStock
  102.      */
  103.     public function setTempId($tempId)
  104.     {
  105.         $this->temp_id $tempId;
  106.         return $this;
  107.     }
  108.     /**
  109.      * Get tempId
  110.      *
  111.      * @return integer
  112.      */
  113.     public function getTempId()
  114.     {
  115.         return $this->temp_id;
  116.     }
  117.     /**
  118.      * Set url
  119.      *
  120.      * @param string $url
  121.      *
  122.      * @return InStock
  123.      */
  124.     public function setUrl($url)
  125.     {
  126.         $this->url $url;
  127.         return $this;
  128.     }
  129.     /**
  130.      * Get url
  131.      *
  132.      * @return string
  133.      */
  134.     public function getUrl()
  135.     {
  136.         return $this->url;
  137.     }
  138.     /**
  139.      * Set state
  140.      *
  141.      * @param integer $state
  142.      *
  143.      * @return InStock
  144.      */
  145.     public function setState($state)
  146.     {
  147.         $this->state $state;
  148.         return $this;
  149.     }
  150.     /**
  151.      * Get state
  152.      *
  153.      * @return integer
  154.      */
  155.     public function getState()
  156.     {
  157.         return $this->state 0;
  158.     }
  159.     /**
  160.      * Set addCost
  161.      *
  162.      * @param integer $addCost
  163.      *
  164.      * @return InStock
  165.      */
  166.     public function setAddCost($addCost)
  167.     {
  168.         $this->add_cost $addCost;
  169.         return $this;
  170.     }
  171.     /**
  172.      * Get addCost
  173.      *
  174.      * @return integer
  175.      */
  176.     public function getAddCost()
  177.     {
  178.         return $this->add_cost;
  179.     }
  180.     /**
  181.      * Set actionPrice
  182.      *
  183.      * @param integer $actionPrice
  184.      *
  185.      * @return InStock
  186.      */
  187.     public function setActionPrice($actionPrice)
  188.     {
  189.         $this->action_price $actionPrice;
  190.         return $this;
  191.     }
  192.     /**
  193.      * Get actionPrice
  194.      *
  195.      * @return integer
  196.      */
  197.     public function getActionPrice()
  198.     {
  199.         return $this->action_price;
  200.     }
  201.     /**
  202.      * Set priceUsd
  203.      *
  204.      * @param integer $priceUsd
  205.      *
  206.      * @return InStock
  207.      */
  208.     public function setPriceUsd($priceUsd)
  209.     {
  210.         $this->price_usd $priceUsd;
  211.         return $this;
  212.     }
  213.     /**
  214.      * Get priceUsd
  215.      *
  216.      * @return integer
  217.      */
  218.     public function getPriceUsd()
  219.     {
  220.         return $this->price_usd;
  221.     }
  222.     /**
  223.      * Set actionPriceUsd
  224.      *
  225.      * @param integer $actionPriceUsd
  226.      *
  227.      * @return InStock
  228.      */
  229.     public function setActionPriceUsd($actionPriceUsd)
  230.     {
  231.         $this->action_price_usd $actionPriceUsd;
  232.         return $this;
  233.     }
  234.     /**
  235.      * Get actionPriceUsd
  236.      *
  237.      * @return integer
  238.      */
  239.     public function getActionPriceUsd()
  240.     {
  241.         return $this->action_price_usd;
  242.     }
  243.     /**
  244.      * Set color
  245.      *
  246.      * @param string $color
  247.      *
  248.      * @return InStock
  249.      */
  250.     public function setColor($color)
  251.     {
  252.         $this->color $color;
  253.         return $this;
  254.     }
  255.     /**
  256.      * Get color
  257.      *
  258.      * @return string
  259.      */
  260.     public function getColor()
  261.     {
  262.         return $this->color;
  263.     }
  264.     /**
  265.      * Set vin
  266.      *
  267.      * @param string $vin
  268.      *
  269.      * @return InStock
  270.      */
  271.     public function setVin($vin)
  272.     {
  273.         $this->vin $vin;
  274.         return $this;
  275.     }
  276.     /**
  277.      * Get vin
  278.      *
  279.      * @return string
  280.      */
  281.     public function getVin()
  282.     {
  283.         return $this->vin;
  284.     }
  285.     /**
  286.      * Set preview
  287.      *
  288.      * @param Media $preview
  289.      *
  290.      * @return InStock
  291.      */
  292.     public function setPreview(Media $preview null)
  293.     {
  294.         $this->preview $preview;
  295.         return $this;
  296.     }
  297.     /**
  298.      * Get preview
  299.      *
  300.      * @return Media
  301.      */
  302.     public function getPreview()
  303.     {
  304.         return $this->preview;
  305.     }
  306.     /**
  307.      * Set gallery
  308.      *
  309.      * @param Gallery $gallery
  310.      *
  311.      * @return InStock
  312.      */
  313.     public function setGallery(Gallery $gallery null)
  314.     {
  315.         $this->gallery $gallery;
  316.         return $this;
  317.     }
  318.     /**
  319.      * Get gallery
  320.      *
  321.      * @return Gallery
  322.      */
  323.     public function getGallery()
  324.     {
  325.         return $this->gallery;
  326.     }
  327.     /**
  328.      * Set video
  329.      *
  330.      * @param Gallery $video
  331.      *
  332.      * @return InStock
  333.      */
  334.     public function setVideo(Gallery $video null)
  335.     {
  336.         $this->video $video;
  337.         return $this;
  338.     }
  339.     /**
  340.      * Get video
  341.      *
  342.      * @return Gallery
  343.      */
  344.     public function getVideo()
  345.     {
  346.         return $this->video;
  347.     }
  348.     /**
  349.      * Add content
  350.      *
  351.      * @param InStockContent $content
  352.      *
  353.      * @return InStock
  354.      */
  355.     public function addContent(InStockContent $content)
  356.     {
  357.         $this->content[] = $content;
  358.         return $this;
  359.     }
  360.     /**
  361.      * Remove content
  362.      *
  363.      * @param InStockContent $content
  364.      */
  365.     public function removeContent(InStockContent $content)
  366.     {
  367.         $this->content->removeElement($content);
  368.     }
  369.     /**
  370.      * Get content
  371.      *
  372.      * @return Collection
  373.      */
  374.     public function getContent()
  375.     {
  376.         return $this->content;
  377.     }
  378.     public function getContentByLocale($locale)
  379.     {
  380.         /** @var InStockContent $iContent */
  381.         foreach ($this->content as $iContent) {
  382.             if($iContent->getLanguage() == $locale) {
  383.                 return $iContent;
  384.             }
  385.         }
  386.         return $this->content->first();
  387.     }
  388.     /**
  389.      * Set vehicleItem
  390.      *
  391.      * @param VehicleItem $vehicleItem
  392.      *
  393.      * @return InStock
  394.      */
  395.     public function setVehicleItem(VehicleItem $vehicleItem null)
  396.     {
  397.         $this->vehicle_item $vehicleItem;
  398.         return $this;
  399.     }
  400.     /**
  401.      * Get vehicleItem
  402.      *
  403.      * @return VehicleItem
  404.      */
  405.     public function getVehicleItem()
  406.     {
  407.         return $this->vehicle_item;
  408.     }
  409.     public function calcPrice()
  410.     {
  411.         if($this->action_price) {
  412.             return $this->action_price;
  413.         }
  414.         if($this->action_price_usd) {
  415.             $rate $this->getVehicleItem()->getVariation()->getVehicle()->getDealer()->getRate();
  416.             return round($this->action_price_usd $rate);
  417.         }
  418.         if($this->price_usd) {
  419.             $rate $this->getVehicleItem()->getVariation()->getVehicle()->getDealer()->getRate();
  420.             return round($this->price_usd $rate);
  421.         }
  422.         return round($this->getVehicleItem()->calcPrice() + $this->add_cost);
  423.     }
  424.     public function formatedPrice(): string
  425.     {
  426.         return number_format($this->calcPrice(),0,'.',' ');
  427.     }
  428.     /**
  429.      * @var string
  430.      */
  431.     private $is_delete 0;
  432.     /**
  433.      * Set isDelete
  434.      *
  435.      * @param string $isDelete
  436.      *
  437.      * @return InStock
  438.      */
  439.     public function setIsDelete($isDelete)
  440.     {
  441.         $this->is_delete $isDelete;
  442.         return $this;
  443.     }
  444.     /**
  445.      * Get isDelete
  446.      *
  447.      * @return string
  448.      */
  449.     public function getIsDelete()
  450.     {
  451.         return $this->is_delete;
  452.     }
  453.     public function __toString()
  454.     {
  455.         $VehicleItem $this->getVehicleItem();
  456.         if(!$VehicleItem) {
  457.             return '';
  458.         }
  459.         $Name = (string) $VehicleItem->getVehicle()->getModel();
  460.         if($VehicleItem->getSpecification()) {
  461.             $Name .= ' '.$VehicleItem->getSpecification()->getTitleRu();
  462.         }
  463.         $Name .= ' '.$this->getColor();
  464.         return $Name;
  465.     }
  466.     /**
  467.      * @var integer
  468.      */
  469.     private $in_delivery 0;
  470.     /**
  471.      * Set inDelivery
  472.      *
  473.      * @param integer $inDelivery
  474.      *
  475.      * @return InStock
  476.      */
  477.     public function setInDelivery($inDelivery)
  478.     {
  479.         $this->in_delivery $inDelivery;
  480.         return $this;
  481.     }
  482.     /**
  483.      * Get inDelivery
  484.      *
  485.      * @return integer
  486.      */
  487.     public function getInDelivery()
  488.     {
  489.         return $this->in_delivery 0;
  490.     }
  491.     /**
  492.      * @var ConfiguratorColor
  493.      */
  494.     private $color_item;
  495.     /**
  496.      * Set colorItem
  497.      *
  498.      * @param ConfiguratorColor $colorItem
  499.      *
  500.      * @return InStock
  501.      */
  502.     public function setColorItem(ConfiguratorColor $colorItem null)
  503.     {
  504.         $this->color_item $colorItem;
  505.         return $this;
  506.     }
  507.     /**
  508.      * Get colorItem
  509.      *
  510.      * @return ConfiguratorColor
  511.      */
  512.     public function getColorItem()
  513.     {
  514.         return $this->color_item;
  515.     }
  516.     /**
  517.      * @var integer
  518.      */
  519.     private $mileage;
  520.     /**
  521.      * Set mileage
  522.      *
  523.      * @param integer $mileage
  524.      *
  525.      * @return InStock
  526.      */
  527.     public function setMileage($mileage)
  528.     {
  529.         $this->mileage $mileage;
  530.         return $this;
  531.     }
  532.     /**
  533.      * Get mileage
  534.      *
  535.      * @return integer
  536.      */
  537.     public function getMileage()
  538.     {
  539.         return $this->mileage;
  540.     }
  541.     /**
  542.      * @var Collection
  543.      */
  544.     private $parts;
  545.     /**
  546.      * Add part
  547.      *
  548.      * @param InStockPart $part
  549.      *
  550.      * @return InStock
  551.      */
  552.     public function addPart(InStockPart $part)
  553.     {
  554.         $this->parts[] = $part;
  555.         return $this;
  556.     }
  557.     /**
  558.      * Remove part
  559.      *
  560.      * @param InStockPart $part
  561.      */
  562.     public function removePart(InStockPart $part)
  563.     {
  564.         $this->parts->removeElement($part);
  565.     }
  566.     /**
  567.      * Get parts
  568.      *
  569.      * @return Collection
  570.      */
  571.     public function getParts()
  572.     {
  573.         return $this->parts;
  574.     }
  575.     /**
  576.      * @var boolean
  577.      */
  578.     private $in_storage 0;
  579.     /**
  580.      * @var boolean
  581.      */
  582.     private $is_reserved 0;
  583.     /**
  584.      * Set inStorage
  585.      *
  586.      * @param boolean $inStorage
  587.      *
  588.      * @return InStock
  589.      */
  590.     public function setInStorage($inStorage)
  591.     {
  592.         $this->in_storage $inStorage;
  593.         return $this;
  594.     }
  595.     /**
  596.      * Get inStorage
  597.      *
  598.      * @return boolean
  599.      */
  600.     public function getInStorage()
  601.     {
  602.         return (boolean)$this->in_storage;
  603.     }
  604.     /**
  605.      * Set isReserved
  606.      *
  607.      * @param boolean $isReserved
  608.      *
  609.      * @return InStock
  610.      */
  611.     public function setIsReserved($isReserved)
  612.     {
  613.         $this->is_reserved $isReserved;
  614.         return $this;
  615.     }
  616.     /**
  617.      * Get isReserved
  618.      *
  619.      * @return boolean
  620.      */
  621.     public function getIsReserved()
  622.     {
  623.         return (boolean)$this->is_reserved;
  624.     }
  625.     /**
  626.      * @var boolean
  627.      */
  628.     private $specify_price 0;
  629.     /**
  630.      * Set specifyPrice
  631.      *
  632.      * @param boolean $specifyPrice
  633.      *
  634.      * @return InStock
  635.      */
  636.     public function setSpecifyPrice($specifyPrice)
  637.     {
  638.         $this->specify_price $specifyPrice;
  639.         return $this;
  640.     }
  641.     /**
  642.      * Get specifyPrice
  643.      *
  644.      * @return boolean
  645.      */
  646.     public function getSpecifyPrice()
  647.     {
  648.         return (boolean) $this->specify_price;
  649.     }
  650.     /**
  651.      * @var integer
  652.      */
  653.     private $delivery_term 0;
  654.     /**
  655.      * Set deliveryTerm
  656.      *
  657.      * @param integer $deliveryTerm
  658.      *
  659.      * @return InStock
  660.      */
  661.     public function setDeliveryTerm($deliveryTerm)
  662.     {
  663.         $this->delivery_term $deliveryTerm;
  664.         return $this;
  665.     }
  666.     /**
  667.      * Get deliveryTerm
  668.      *
  669.      * @return integer
  670.      */
  671.     public function getDeliveryTerm()
  672.     {
  673.         return $this->delivery_term;
  674.     }
  675.     /**
  676.      * @var Media
  677.      */
  678.     private $preview_second;
  679.     /**
  680.      * Set previewSecond
  681.      *
  682.      * @param Media $previewSecond
  683.      *
  684.      * @return InStock
  685.      */
  686.     public function setPreviewSecond(Media $previewSecond null)
  687.     {
  688.         $this->preview_second $previewSecond;
  689.         return $this;
  690.     }
  691.     /**
  692.      * Get previewSecond
  693.      *
  694.      * @return Media
  695.      */
  696.     public function getPreviewSecond()
  697.     {
  698.         return $this->preview_second;
  699.     }
  700.     /**
  701.      * @var bool
  702.      */
  703.     private $to_order 0;
  704.     /**
  705.      * Set toOrder.
  706.      *
  707.      * @param bool $toOrder
  708.      *
  709.      * @return InStock
  710.      */
  711.     public function setToOrder($toOrder)
  712.     {
  713.         $this->to_order $toOrder;
  714.         return $this;
  715.     }
  716.     /**
  717.      * Get toOrder.
  718.      *
  719.      * @return boolean
  720.      */
  721.     public function getToOrder()
  722.     {
  723.         return (boolean) $this->to_order;
  724.     }
  725.     public function setVehicleCardType(?VehicleCardType $vehicleCardType): InStock
  726.     {
  727.         $this->vehicleCardType $vehicleCardType;
  728.         if ($vehicleCardType !== null) {
  729.             $vehicleCardType->setInStockVehicle($this);
  730.         }
  731.         return $this;
  732.     }
  733.     public function getVehicleCardType(): ?VehicleCardType
  734.     {
  735.         return $this->vehicleCardType;
  736.     }
  737.     /**
  738.      * @var bool
  739.      */
  740.     private $e_power 0;
  741.     /**
  742.      * Set ePower.
  743.      *
  744.      * @param bool $ePower
  745.      *
  746.      * @return InStock
  747.      */
  748.     public function setEPower($ePower)
  749.     {
  750.         $this->e_power $ePower;
  751.         return $this;
  752.     }
  753.     /**
  754.      * Get ePower.
  755.      *
  756.      * @return bool
  757.      */
  758.     public function getEPower()
  759.     {
  760.         return (boolean) $this->e_power;
  761.     }
  762.     /**
  763.      * @var DateTime
  764.      */
  765.     private $date_create;
  766.     /**
  767.      * Set dateCreate.
  768.      *
  769.      * @param DateTime $dateCreate
  770.      *
  771.      * @return InStock
  772.      */
  773.     public function setDateCreate($dateCreate)
  774.     {
  775.         $this->date_create $dateCreate;
  776.         return $this;
  777.     }
  778.     /**
  779.      * Get dateCreate.
  780.      *
  781.      * @return DateTime
  782.      */
  783.     public function getDateCreate()
  784.     {
  785.         return $this->date_create;
  786.     }
  787.     /**
  788.      * @var bool
  789.      */
  790.     private $page_main 0;
  791.     /**
  792.      * Set pageMain.
  793.      *
  794.      * @param bool $pageMain
  795.      *
  796.      * @return InStock
  797.      */
  798.     public function setPageMain($pageMain)
  799.     {
  800.         $this->page_main $pageMain;
  801.         return $this;
  802.     }
  803.     /**
  804.      * Get pageMain.
  805.      *
  806.      * @return bool
  807.      */
  808.     public function getPageMain()
  809.     {
  810.         return (boolean) $this->page_main;
  811.     }
  812.     public function getUpdatedAt(): DateTime
  813.     {
  814.         return $this->updatedAt;
  815.     }
  816.     public function setUpdatedAt(): self
  817.     {
  818.         $this->updatedAt = new \DateTime();
  819.         return $this;
  820.     }
  821. }