<?php
namespace App\Entity\Report;
use App\Entity\Recommendation;
use App\Repository\Report\ReportValueRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=ReportValueRepository::class)
*/
class ReportValue
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $norm;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $image;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $comment;
/**
* @ORM\Column(type="integer")
*/
private $parameter;
/**
* @ORM\ManyToOne(targetEntity=Report::class, inversedBy="reportValues", cascade={"persist"})
*/
private $report;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default": false})
*/
private $copyImage;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $coordinate;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $distance;
/**
* @ORM\OneToMany(targetEntity=Recommendation::class, mappedBy="reportValue",cascade={"persist","remove"})
*/
private $recommendations;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $cropWiseLoad;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $cropWiseLoadImage;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $scoutReportPointMeasurementId;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $ii;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $storageImage;
/**
* @ORM\Column(type="boolean", nullable=true, options={"default":0})
*/
private $alert;
public function __construct()
{
if ($this->id === null) {
$this->copyImage = false;
}
$this->recommendations = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNorm(): ?string
{
return $this->norm;
}
public function setNorm(?string $norm): self
{
$this->norm = $norm;
return $this;
}
public function getImage(): ?string
{
return $this->image;
}
public function setImage(?string $image): self
{
$this->image = $image;
return $this;
}
public function getComment(): ?string
{
return $this->comment;
}
public function setComment(?string $comment): self
{
$this->comment = $comment;
return $this;
}
public function getParameter(): ?int
{
return $this->parameter;
}
public function setParameter(int $parameter): self
{
$this->parameter = $parameter;
return $this;
}
public function getReport(): ?Report
{
return $this->report;
}
public function setReport(?Report $report): self
{
$this->report = $report;
return $this;
}
public function isCopyImage(): ?bool
{
return $this->copyImage;
}
public function setCopyImage(?bool $copyImage): self
{
$this->copyImage = $copyImage;
return $this;
}
/**
* @return mixed
*/
public function getCoordinate()
{
return $this->coordinate;
}
/**
* @param mixed $coordinate
*/
public function setCoordinate($coordinate): void
{
$this->coordinate = $coordinate;
}
public function getCoordinatesArray(): array
{
$coordinate = str_replace('-', ' ', $this->coordinate);
$coordinate = preg_replace('@\s+@', ' ', $coordinate);
$explode = explode(' ', $coordinate);
try {
list($lat,$lng) = $explode;
return [
'lng' => $lng,
'lat' => $lat,
];
} catch (\Exception $e) {
return [];
}
}
/**
* @return mixed
*/
public function getDistance()
{
return $this->distance;
}
/**
* @param mixed $distance
*/
public function setDistance($distance): void
{
$this->distance = $distance;
}
/**
* @return Collection<int, Recommendation>
*/
public function getRecommendations(): Collection
{
return $this->recommendations;
}
public function addRecommendation(Recommendation $recommendation): self
{
if (!$this->recommendations->contains($recommendation)) {
$this->recommendations[] = $recommendation;
$recommendation->setReportValue($this);
}
return $this;
}
public function removeRecommendation(Recommendation $recommendation): self
{
if ($this->recommendations->removeElement($recommendation)) {
// set the owning side to null (unless already changed)
if ($recommendation->getReportValue() === $this) {
$recommendation->setReportValue(null);
}
}
return $this;
}
public function getCropWiseLoad(): ?string
{
return $this->cropWiseLoad;
}
public function setCropWiseLoad(?string $cropWiseLoad): self
{
$this->cropWiseLoad = $cropWiseLoad;
return $this;
}
public function isCropWiseLoadImage(): ?bool
{
return $this->cropWiseLoadImage;
}
public function setCropWiseLoadImage(?bool $cropWiseLoadImage): self
{
$this->cropWiseLoadImage = $cropWiseLoadImage;
return $this;
}
public function getScoutReportPointMeasurementId(): ?int
{
return $this->scoutReportPointMeasurementId;
}
public function setScoutReportPointMeasurementId(?int $scoutReportPointMeasurementId): self
{
$this->scoutReportPointMeasurementId = $scoutReportPointMeasurementId;
return $this;
}
public function getIi(): ?string
{
return $this->ii;
}
public function setIi(?string $ii): self
{
$this->ii = $ii;
return $this;
}
public function getStorageImage(): ?string
{
if(!empty($this->storageImage) && strpos($this->storageImage,'http') === false){
return $_ENV['SELECTEL_STORAGE_PUBLIC_DOMAIN']."/".$this->storageImage;
}
return $this->storageImage;
}
public function setStorageImage(?string $storageImage): self
{
$this->storageImage = $storageImage;
return $this;
}
/**
* @return mixed
*/
public function getAlert()
{
return $this->alert;
}
/**
* @param mixed $alert
*/
public function setAlert($alert): void
{
$this->alert = $alert;
}
}