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.         $rate $this->getVehicleItem()?->getVariation()?->getVehicle()?->getDealer()?->getRate();
  415.         if($this->action_price_usd) {
  416.             return round($this->action_price_usd $rate);
  417.         }
  418.         if($this->price_usd) {
  419.             return round($this->price_usd $rate);
  420.         }
  421.         return round($this->getVehicleItem()?->calcPrice() + $this->add_cost);
  422.     }
  423.     public function formatedPrice(): string
  424.     {
  425.         return number_format($this->calcPrice(),0,'.',' ');
  426.     }
  427.     /**
  428.      * @var string
  429.      */
  430.     private $is_delete 0;
  431.     /**
  432.      * Set isDelete
  433.      *
  434.      * @param string $isDelete
  435.      *
  436.      * @return InStock
  437.      */
  438.     public function setIsDelete($isDelete)
  439.     {
  440.         $this->is_delete $isDelete;
  441.         return $this;
  442.     }
  443.     /**
  444.      * Get isDelete
  445.      *
  446.      * @return string
  447.      */
  448.     public function getIsDelete()
  449.     {
  450.         return $this->is_delete;
  451.     }
  452.     public function __toString()
  453.     {
  454.         $VehicleItem $this->getVehicleItem();
  455.         if(!$VehicleItem) {
  456.             return '';
  457.         }
  458.         $Name = (string) $VehicleItem->getVehicle()->getModel();
  459.         if($VehicleItem->getSpecification()) {
  460.             $Name .= ' '.$VehicleItem->getSpecification()->getTitleRu();
  461.         }
  462.         $Name .= ' '.$this->getColor();
  463.         return $Name;
  464.     }
  465.     /**
  466.      * @var integer
  467.      */
  468.     private $in_delivery 0;
  469.     /**
  470.      * Set inDelivery
  471.      *
  472.      * @param integer $inDelivery
  473.      *
  474.      * @return InStock
  475.      */
  476.     public function setInDelivery($inDelivery)
  477.     {
  478.         $this->in_delivery $inDelivery;
  479.         return $this;
  480.     }
  481.     /**
  482.      * Get inDelivery
  483.      *
  484.      * @return integer
  485.      */
  486.     public function getInDelivery()
  487.     {
  488.         return $this->in_delivery 0;
  489.     }
  490.     /**
  491.      * @var ConfiguratorColor
  492.      */
  493.     private $color_item;
  494.     /**
  495.      * Set colorItem
  496.      *
  497.      * @param ConfiguratorColor $colorItem
  498.      *
  499.      * @return InStock
  500.      */
  501.     public function setColorItem(ConfiguratorColor $colorItem null)
  502.     {
  503.         $this->color_item $colorItem;
  504.         return $this;
  505.     }
  506.     /**
  507.      * Get colorItem
  508.      *
  509.      * @return ConfiguratorColor
  510.      */
  511.     public function getColorItem()
  512.     {
  513.         return $this->color_item;
  514.     }
  515.     /**
  516.      * @var integer
  517.      */
  518.     private $mileage;
  519.     /**
  520.      * Set mileage
  521.      *
  522.      * @param integer $mileage
  523.      *
  524.      * @return InStock
  525.      */
  526.     public function setMileage($mileage)
  527.     {
  528.         $this->mileage $mileage;
  529.         return $this;
  530.     }
  531.     /**
  532.      * Get mileage
  533.      *
  534.      * @return integer
  535.      */
  536.     public function getMileage()
  537.     {
  538.         return $this->mileage;
  539.     }
  540.     /**
  541.      * @var Collection
  542.      */
  543.     private $parts;
  544.     /**
  545.      * Add part
  546.      *
  547.      * @param InStockPart $part
  548.      *
  549.      * @return InStock
  550.      */
  551.     public function addPart(InStockPart $part)
  552.     {
  553.         $this->parts[] = $part;
  554.         return $this;
  555.     }
  556.     /**
  557.      * Remove part
  558.      *
  559.      * @param InStockPart $part
  560.      */
  561.     public function removePart(InStockPart $part)
  562.     {
  563.         $this->parts->removeElement($part);
  564.     }
  565.     /**
  566.      * Get parts
  567.      *
  568.      * @return Collection
  569.      */
  570.     public function getParts()
  571.     {
  572.         return $this->parts;
  573.     }
  574.     /**
  575.      * @var boolean
  576.      */
  577.     private $in_storage 0;
  578.     /**
  579.      * @var boolean
  580.      */
  581.     private $is_reserved 0;
  582.     /**
  583.      * Set inStorage
  584.      *
  585.      * @param boolean $inStorage
  586.      *
  587.      * @return InStock
  588.      */
  589.     public function setInStorage($inStorage)
  590.     {
  591.         $this->in_storage $inStorage;
  592.         return $this;
  593.     }
  594.     /**
  595.      * Get inStorage
  596.      *
  597.      * @return boolean
  598.      */
  599.     public function getInStorage()
  600.     {
  601.         return (boolean)$this->in_storage;
  602.     }
  603.     /**
  604.      * Set isReserved
  605.      *
  606.      * @param boolean $isReserved
  607.      *
  608.      * @return InStock
  609.      */
  610.     public function setIsReserved($isReserved)
  611.     {
  612.         $this->is_reserved $isReserved;
  613.         return $this;
  614.     }
  615.     /**
  616.      * Get isReserved
  617.      *
  618.      * @return boolean
  619.      */
  620.     public function getIsReserved()
  621.     {
  622.         return (boolean)$this->is_reserved;
  623.     }
  624.     /**
  625.      * @var boolean
  626.      */
  627.     private $specify_price 0;
  628.     /**
  629.      * Set specifyPrice
  630.      *
  631.      * @param boolean $specifyPrice
  632.      *
  633.      * @return InStock
  634.      */
  635.     public function setSpecifyPrice($specifyPrice)
  636.     {
  637.         $this->specify_price $specifyPrice;
  638.         return $this;
  639.     }
  640.     /**
  641.      * Get specifyPrice
  642.      *
  643.      * @return boolean
  644.      */
  645.     public function getSpecifyPrice()
  646.     {
  647.         return (boolean) $this->specify_price;
  648.     }
  649.     /**
  650.      * @var integer
  651.      */
  652.     private $delivery_term 0;
  653.     /**
  654.      * Set deliveryTerm
  655.      *
  656.      * @param integer $deliveryTerm
  657.      *
  658.      * @return InStock
  659.      */
  660.     public function setDeliveryTerm($deliveryTerm)
  661.     {
  662.         $this->delivery_term $deliveryTerm;
  663.         return $this;
  664.     }
  665.     /**
  666.      * Get deliveryTerm
  667.      *
  668.      * @return integer
  669.      */
  670.     public function getDeliveryTerm()
  671.     {
  672.         return $this->delivery_term;
  673.     }
  674.     /**
  675.      * @var Media
  676.      */
  677.     private $preview_second;
  678.     /**
  679.      * Set previewSecond
  680.      *
  681.      * @param Media $previewSecond
  682.      *
  683.      * @return InStock
  684.      */
  685.     public function setPreviewSecond(Media $previewSecond null)
  686.     {
  687.         $this->preview_second $previewSecond;
  688.         return $this;
  689.     }
  690.     /**
  691.      * Get previewSecond
  692.      *
  693.      * @return Media
  694.      */
  695.     public function getPreviewSecond()
  696.     {
  697.         return $this->preview_second;
  698.     }
  699.     /**
  700.      * @var bool
  701.      */
  702.     private $to_order 0;
  703.     /**
  704.      * Set toOrder.
  705.      *
  706.      * @param bool $toOrder
  707.      *
  708.      * @return InStock
  709.      */
  710.     public function setToOrder($toOrder)
  711.     {
  712.         $this->to_order $toOrder;
  713.         return $this;
  714.     }
  715.     /**
  716.      * Get toOrder.
  717.      *
  718.      * @return boolean
  719.      */
  720.     public function getToOrder()
  721.     {
  722.         return (boolean) $this->to_order;
  723.     }
  724.     public function setVehicleCardType(?VehicleCardType $vehicleCardType): InStock
  725.     {
  726.         $this->vehicleCardType $vehicleCardType;
  727.         if ($vehicleCardType !== null) {
  728.             $vehicleCardType->setInStockVehicle($this);
  729.         }
  730.         return $this;
  731.     }
  732.     public function getVehicleCardType(): ?VehicleCardType
  733.     {
  734.         return $this->vehicleCardType;
  735.     }
  736.     /**
  737.      * @var bool
  738.      */
  739.     private $e_power 0;
  740.     /**
  741.      * Set ePower.
  742.      *
  743.      * @param bool $ePower
  744.      *
  745.      * @return InStock
  746.      */
  747.     public function setEPower($ePower)
  748.     {
  749.         $this->e_power $ePower;
  750.         return $this;
  751.     }
  752.     /**
  753.      * Get ePower.
  754.      *
  755.      * @return bool
  756.      */
  757.     public function getEPower()
  758.     {
  759.         return (boolean) $this->e_power;
  760.     }
  761.     /**
  762.      * @var DateTime
  763.      */
  764.     private $date_create;
  765.     /**
  766.      * Set dateCreate.
  767.      *
  768.      * @param DateTime $dateCreate
  769.      *
  770.      * @return InStock
  771.      */
  772.     public function setDateCreate($dateCreate)
  773.     {
  774.         $this->date_create $dateCreate;
  775.         return $this;
  776.     }
  777.     /**
  778.      * Get dateCreate.
  779.      *
  780.      * @return DateTime
  781.      */
  782.     public function getDateCreate()
  783.     {
  784.         return $this->date_create;
  785.     }
  786.     /**
  787.      * @var bool
  788.      */
  789.     private $page_main 0;
  790.     /**
  791.      * Set pageMain.
  792.      *
  793.      * @param bool $pageMain
  794.      *
  795.      * @return InStock
  796.      */
  797.     public function setPageMain($pageMain)
  798.     {
  799.         $this->page_main $pageMain;
  800.         return $this;
  801.     }
  802.     /**
  803.      * Get pageMain.
  804.      *
  805.      * @return bool
  806.      */
  807.     public function getPageMain()
  808.     {
  809.         return (boolean) $this->page_main;
  810.     }
  811.     public function getUpdatedAt(): DateTime
  812.     {
  813.         return $this->updatedAt;
  814.     }
  815.     public function setUpdatedAt(): self
  816.     {
  817.         $this->updatedAt = new \DateTime();
  818.         return $this;
  819.     }
  820. }