* initial commit
This commit is contained in:
346
src/App/Entity/Attachment.php
Normal file
346
src/App/Entity/Attachment.php
Normal file
@@ -0,0 +1,346 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Event\LifecycleEventArgs;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Imagine\Image\Box;
|
||||
use Imagine\Image\ImageInterface;
|
||||
use Imagine\Gd\Imagine;
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="attachments",
|
||||
* indexes={
|
||||
* @ORM\Index(name="AT_type_idx", columns={"type"}),
|
||||
* @ORM\Index(name="AT_active_idx", columns={"active"})
|
||||
* }
|
||||
* )
|
||||
* @ORM\HasLifecycleCallbacks
|
||||
*/
|
||||
class Attachment implements JsonSerializable
|
||||
{
|
||||
|
||||
const MAX_PIXEL_SPREAD = 3200;
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="IDENTITY")
|
||||
* @var int
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="fault_id", nullable=false)
|
||||
* @ORM\ManyToOne(targetEntity="Fault", inversedBy="attachments")
|
||||
* @var Fault
|
||||
*/
|
||||
private $fault;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="user_id", nullable=false)
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="attachments")
|
||||
* @var User
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Type can be image or invoice
|
||||
*
|
||||
* @ORM\Column(name="type", type="string", length=50, nullable=false)
|
||||
* @var string
|
||||
*/
|
||||
private $type = 'image';
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="active", type="boolean", options={"default": true})
|
||||
* @var bool
|
||||
*/
|
||||
private $active = true;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $rawFileData = null;
|
||||
|
||||
/**
|
||||
* Temporary variably, only used for entity postRemove hook
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $idPreDeleteTemp;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return Attachment
|
||||
*/
|
||||
public function setId(int $id): Attachment
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Fault
|
||||
*/
|
||||
public function getFault(): Fault
|
||||
{
|
||||
return $this->fault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Fault $fault
|
||||
* @return Attachment
|
||||
*/
|
||||
public function setFault(Fault $fault)
|
||||
{
|
||||
$this->fault = $fault;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getUser(): User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return Attachment
|
||||
*/
|
||||
public function setUser(User $user): Attachment
|
||||
{
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @return Attachment
|
||||
*/
|
||||
public function setType(string $type): Attachment
|
||||
{
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function getActive(): bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $active
|
||||
* @return Attachment
|
||||
*/
|
||||
public function setActive(bool $active): Attachment
|
||||
{
|
||||
$this->active = $active;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRawFileData(): string
|
||||
{
|
||||
return $this->rawFileData;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $rawFileData
|
||||
* @return Attachment
|
||||
*/
|
||||
public function setRawFileData(string $rawFileData): Attachment
|
||||
{
|
||||
$this->rawFileData = $rawFileData;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PrePersist
|
||||
* @return Attachment
|
||||
*/
|
||||
public function validatePrePersist(): Attachment
|
||||
{
|
||||
if ($this->getRawFileData() == null) {
|
||||
throw new \InvalidArgumentException("File data can't be empty");
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PostPersist
|
||||
* @return Attachment
|
||||
*/
|
||||
public function saveOnPersist(): Attachment
|
||||
{
|
||||
if ($this->getType() == 'image') {
|
||||
return $this->saveDataAsImageFile($this->rawFileData);
|
||||
}
|
||||
|
||||
return $this->saveDataAsBinaryFile($this->rawFileData);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PreRemove
|
||||
* @return Attachment
|
||||
*/
|
||||
public function preDeleteHelper(): Attachment
|
||||
{
|
||||
$this->idPreDeleteTemp = $this->id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\PostRemove
|
||||
* @return Attachment
|
||||
*/
|
||||
public function deleteImage(): Attachment
|
||||
{
|
||||
unlink($this->getFileName($this->idPreDeleteTemp));
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $rawFileData
|
||||
* @return Attachment
|
||||
*/
|
||||
public function saveDataAsImageFile(string $rawFileData): Attachment
|
||||
{
|
||||
$folder = $this->getContainingFolder();
|
||||
if (!file_exists($folder)) {
|
||||
mkdir($folder, 0755, true);
|
||||
}
|
||||
|
||||
$extendedId = $this->getExtendedId();
|
||||
$pathSplit = str_split($extendedId, 3);
|
||||
$fileName = array_pop($pathSplit);
|
||||
$imagine = new Imagine();
|
||||
$image = $imagine->load($rawFileData);
|
||||
$originBox = $image->getSize();
|
||||
$originWidth = $originBox->getWidth();
|
||||
$originHeight = $originBox->getHeight();
|
||||
if ($originWidth > self::MAX_PIXEL_SPREAD || $originHeight > self::MAX_PIXEL_SPREAD) {
|
||||
if ($originWidth > $originHeight) {
|
||||
$newWidth = self::MAX_PIXEL_SPREAD;
|
||||
$newHeight = floor(self::MAX_PIXEL_SPREAD * $originHeight / $originWidth);
|
||||
} elseif ($originHeight > $originWidth) {
|
||||
$newWidth = floor(self::MAX_PIXEL_SPREAD * $originWidth / $originHeight);
|
||||
$newHeight = self::MAX_PIXEL_SPREAD;
|
||||
} else {
|
||||
$newWidth = self::MAX_PIXEL_SPREAD;
|
||||
$newHeight = self::MAX_PIXEL_SPREAD;
|
||||
}
|
||||
// $image->resize(new Box($newWidth, $newHeight), ImageInterface::FILTER_LANCZOS);
|
||||
$image->resize(new Box($newWidth, $newHeight));
|
||||
$image->effects()->sharpen();
|
||||
}
|
||||
$image->save(sprintf("%s/%s", $folder, $fileName), [
|
||||
'format' => 'jpeg',
|
||||
'jpeg_quality' => 80,
|
||||
]);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function saveDataAsBinaryFile(string $rawFileData): Attachment
|
||||
{
|
||||
$folder = $this->getContainingFolder();
|
||||
if (!file_exists($folder)) {
|
||||
mkdir($folder, 0755, true);
|
||||
}
|
||||
$pathSplit = str_split($this->getExtendedId(), 3);
|
||||
$fileName = array_pop($pathSplit);
|
||||
file_put_contents(sprintf("%s/%s", $folder, $fileName), $rawFileData);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return string
|
||||
*/
|
||||
private function getContainingFolder($id = null): string
|
||||
{
|
||||
$attachmentFolder = str_split($this->getExtendedId($id), 3);
|
||||
array_pop($attachmentFolder);
|
||||
return sprintf('data/attachments/%s', implode('/', $attachmentFolder));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return string
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function getExtendedId($id = null): string
|
||||
{
|
||||
if ($this->id == null && $id == null) {
|
||||
throw new \Exception("Entity must be persisted first.");
|
||||
}
|
||||
|
||||
return sprintf("%09d", $id ? $id : $this->getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return string
|
||||
*/
|
||||
public function getFileName($id = null): string
|
||||
{
|
||||
$splitParts = str_split($this->getExtendedId($id), 3);
|
||||
$fileName = array_pop($splitParts);
|
||||
return sprintf("%s/%s", $this->getContainingFolder($id), $fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return resource
|
||||
*/
|
||||
public function getIoStream()
|
||||
{
|
||||
return fopen($this->getFileName(), 'r');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRawAttachmentData(): string
|
||||
{
|
||||
return file_get_contents($this->getFileName());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'type' => $this->getType(),
|
||||
'active' => $this->getActive(),
|
||||
'user' => $this->getUser(),
|
||||
];
|
||||
}
|
||||
}
|
||||
66
src/App/Entity/AuthResponse.php
Normal file
66
src/App/Entity/AuthResponse.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use JsonSerializable;
|
||||
|
||||
class AuthResponse implements JsonSerializable
|
||||
{
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $message;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $token;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMessage(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $message
|
||||
* @return AuthResponse
|
||||
*/
|
||||
public function setMessage(string $message): AuthResponse
|
||||
{
|
||||
$this->message = $message;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getToken(): string
|
||||
{
|
||||
return $this->token;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $token
|
||||
* @return AuthResponse
|
||||
*/
|
||||
public function setToken(string $token): AuthResponse
|
||||
{
|
||||
$this->token = $token;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'message' => $this->getMessage(),
|
||||
'token' => $this->getToken(),
|
||||
];
|
||||
}
|
||||
}
|
||||
179
src/App/Entity/Device.php
Normal file
179
src/App/Entity/Device.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class Device implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $responsible;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
private $count;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $workDescription;
|
||||
|
||||
/**
|
||||
* @var DeviceMaintenanceTask[]|ArrayCollection
|
||||
*/
|
||||
private $tasks;
|
||||
|
||||
/** @var DeviceGroup */
|
||||
private $group;
|
||||
|
||||
public function __construct(DeviceGroup $group)
|
||||
{
|
||||
$this->group = $group;
|
||||
$this->tasks = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return Device
|
||||
*/
|
||||
public function setName(string $name): Device
|
||||
{
|
||||
$this->name = trim($name);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getResponsible(): string
|
||||
{
|
||||
return $this->responsible;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $responsible
|
||||
* @return Device
|
||||
*/
|
||||
public function setResponsible(string $responsible): Device
|
||||
{
|
||||
$this->responsible = trim($responsible);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCount(): int
|
||||
{
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $count
|
||||
* @return Device
|
||||
*/
|
||||
public function setCount(int $count): Device
|
||||
{
|
||||
$this->count = $count;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getWorkDescription(): string
|
||||
{
|
||||
return $this->workDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $workDescription
|
||||
* @return Device
|
||||
*/
|
||||
public function setWorkDescription(string $workDescription): Device
|
||||
{
|
||||
$this->workDescription = trim($workDescription);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DeviceMaintenanceTask[]|ArrayCollection
|
||||
*/
|
||||
public function getTasks(): ?ArrayCollection
|
||||
{
|
||||
return $this->tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DeviceMaintenanceTask[]|ArrayCollection $tasks
|
||||
* @return Device
|
||||
*/
|
||||
public function setTasks(ArrayCollection $tasks)
|
||||
{
|
||||
$this->tasks = $tasks;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DeviceMaintenanceTask $device
|
||||
* @return Device
|
||||
*/
|
||||
public function addTask(DeviceMaintenanceTask $device): Device
|
||||
{
|
||||
if (!$this->tasks->contains($device)) {
|
||||
$this->tasks->add($device);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DeviceMaintenanceTask $maintenanceTask
|
||||
* @return Device
|
||||
*/
|
||||
public function removeTask(DeviceMaintenanceTask $maintenanceTask): Device
|
||||
{
|
||||
if ($this->tasks->contains($maintenanceTask)) {
|
||||
$this->tasks->removeElement($maintenanceTask);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getGroup(): DeviceGroup
|
||||
{
|
||||
return $this->group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify data which should be serialized to JSON
|
||||
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
|
||||
* @return mixed data which can be serialized by <b>json_encode</b>,
|
||||
* which is a value of any type other than a resource.
|
||||
* @since 5.4.0
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'name' => $this->getName(),
|
||||
'count' => $this->getCount(),
|
||||
'responsible' => $this->getResponsible(),
|
||||
'workDescription' => $this->getWorkDescription(),
|
||||
'tasks' => $this->getTasks()->getValues(),
|
||||
];
|
||||
}
|
||||
}
|
||||
99
src/App/Entity/DeviceGroup.php
Normal file
99
src/App/Entity/DeviceGroup.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class DeviceGroup implements \JsonSerializable
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var Device[]|ArrayCollection
|
||||
*/
|
||||
private $devices;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->devices = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return DeviceGroup
|
||||
*/
|
||||
public function setName(string $name): DeviceGroup
|
||||
{
|
||||
$this->name = trim($name);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Device[]|ArrayCollection
|
||||
*/
|
||||
public function getDevices(): ArrayCollection
|
||||
{
|
||||
return $this->devices;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Device[]|ArrayCollection $devices
|
||||
* @return DeviceGroup
|
||||
*/
|
||||
public function setDevices($devices): DeviceGroup
|
||||
{
|
||||
$this->devices = $devices;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Device $device
|
||||
* @return DeviceGroup
|
||||
*/
|
||||
public function addDevice(Device $device): DeviceGroup
|
||||
{
|
||||
if (!$this->devices->contains($device)) {
|
||||
$this->devices->add($device);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Device $device
|
||||
* @return DeviceGroup
|
||||
*/
|
||||
public function removeDevice(Device $device): DeviceGroup
|
||||
{
|
||||
if ($this->devices->contains($device)) {
|
||||
$this->devices->removeElement($device);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify data which should be serialized to JSON
|
||||
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
|
||||
* @return mixed data which can be serialized by <b>json_encode</b>,
|
||||
* which is a value of any type other than a resource.
|
||||
* @since 5.4.0
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'name' => $this->getName(),
|
||||
'devices' => $this->getDevices()->getValues(),
|
||||
];
|
||||
}
|
||||
}
|
||||
247
src/App/Entity/DeviceMaintenanceTask.php
Normal file
247
src/App/Entity/DeviceMaintenanceTask.php
Normal file
@@ -0,0 +1,247 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
class DeviceMaintenanceTask implements \JsonSerializable
|
||||
{
|
||||
/** @var int */
|
||||
private $year;
|
||||
|
||||
/** @var int */
|
||||
private $month;
|
||||
|
||||
/** @var int */
|
||||
private $week;
|
||||
|
||||
/** @var int */
|
||||
private $workerCount;
|
||||
|
||||
/** @var float */
|
||||
private $timeCost;
|
||||
|
||||
/** @var \DateTime */
|
||||
private $shouldStartAt;
|
||||
|
||||
/** @var \DateTime */
|
||||
private $shouldBeDoneBy;
|
||||
|
||||
/** @var string */
|
||||
private $state = 'new';
|
||||
|
||||
/** @var Device */
|
||||
private $device;
|
||||
|
||||
public function __construct(Device $device)
|
||||
{
|
||||
$this->device = $device;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getYear(): int
|
||||
{
|
||||
return $this->year;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $year
|
||||
* @return DeviceMaintenanceTask
|
||||
*/
|
||||
public function setYear(int $year): DeviceMaintenanceTask
|
||||
{
|
||||
$this->year = $year;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMonth(): int
|
||||
{
|
||||
return $this->month;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $month
|
||||
* @return DeviceMaintenanceTask
|
||||
*/
|
||||
public function setMonth(int $month): DeviceMaintenanceTask
|
||||
{
|
||||
$this->month = $month;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getWeek(): int
|
||||
{
|
||||
return $this->week;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $week
|
||||
* @return DeviceMaintenanceTask
|
||||
*/
|
||||
public function setWeek(int $week): DeviceMaintenanceTask
|
||||
{
|
||||
$this->week = $week;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getWorkerCount(): int
|
||||
{
|
||||
return $this->workerCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $workerCount
|
||||
* @return DeviceMaintenanceTask
|
||||
*/
|
||||
public function setWorkerCount(int $workerCount): DeviceMaintenanceTask
|
||||
{
|
||||
$this->workerCount = $workerCount;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getTimeCost(): float
|
||||
{
|
||||
return $this->timeCost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $timeCost
|
||||
* @return DeviceMaintenanceTask
|
||||
*/
|
||||
public function setTimeCost(float $timeCost): DeviceMaintenanceTask
|
||||
{
|
||||
$this->timeCost = $timeCost;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getShouldStartAt(): \DateTime
|
||||
{
|
||||
return $this->shouldStartAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $shouldStartAt
|
||||
* @return DeviceMaintenanceTask
|
||||
*/
|
||||
public function setShouldStartAt(\DateTime $shouldStartAt): DeviceMaintenanceTask
|
||||
{
|
||||
$this->shouldStartAt = $shouldStartAt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getShouldBeDoneBy(): \DateTime
|
||||
{
|
||||
return $this->shouldBeDoneBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $shouldBeDoneBy
|
||||
* @return DeviceMaintenanceTask
|
||||
*/
|
||||
public function setShouldBeDoneBy(\DateTime $shouldBeDoneBy): DeviceMaintenanceTask
|
||||
{
|
||||
$this->shouldBeDoneBy = $shouldBeDoneBy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isDone(): bool
|
||||
{
|
||||
return $this->state == 'fin';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getState(): string
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $state
|
||||
* @return DeviceMaintenanceTask
|
||||
*/
|
||||
public function setState(string $state): DeviceMaintenanceTask
|
||||
{
|
||||
$this->state = $state;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* device.name + device.workDescription + task.month + task.week
|
||||
* @return string
|
||||
* @deprecated
|
||||
*/
|
||||
public function getLegacyHash(): string
|
||||
{
|
||||
$dirty = $this->device->getName()
|
||||
. $this->device->getWorkDescription()
|
||||
. $this->getMonth() . $this->getWeek();
|
||||
$cleanBaseName = str_replace(" ", "", $dirty);
|
||||
return md5($cleanBaseName);
|
||||
}
|
||||
|
||||
/**
|
||||
* year + device.name + device.workDescription + task.month + task.week
|
||||
* @return string
|
||||
*/
|
||||
public function getHash(): string
|
||||
{
|
||||
$dirty = $this->getYear()
|
||||
. sprintf('%02d', $this->getMonth()) . sprintf('%02d', $this->getWeek())
|
||||
. $this->device->getName()
|
||||
. $this->device->getWorkDescription();
|
||||
$cleanBaseName = str_replace(" ", "", $dirty);
|
||||
return md5($cleanBaseName);
|
||||
}
|
||||
|
||||
public function getDevice(): Device
|
||||
{
|
||||
return $this->device;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify data which should be serialized to JSON
|
||||
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
|
||||
* @return mixed data which can be serialized by <b>json_encode</b>,
|
||||
* which is a value of any type other than a resource.
|
||||
* @since 5.4.0
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'year' => $this->getYear(),
|
||||
'month' => $this->getMonth(),
|
||||
'week' => $this->getWeek(),
|
||||
'workerCount' => $this->getWorkerCount(),
|
||||
'timeCost' => $this->getTimeCost(),
|
||||
'shouldStartAt' => $this->getShouldStartAt()->format("Y-m-d"),
|
||||
'shouldBeDoneBy' => $this->getShouldBeDoneBy()->format("Y-m-d"),
|
||||
'done' => $this->isDone(),
|
||||
'state' => $this->getState(),
|
||||
'hash' => $this->getHash(),
|
||||
'legacyHash' => $this->getLegacyHash(),
|
||||
];
|
||||
}
|
||||
}
|
||||
154
src/App/Entity/ErrorCategory.php
Normal file
154
src/App/Entity/ErrorCategory.php
Normal file
@@ -0,0 +1,154 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="error_categories",
|
||||
* indexes={
|
||||
* @ORM\Index(name="EC_type_idx", columns={"type"}),
|
||||
* @ORM\Index(name="EC_active_idx", columns={"active"})
|
||||
* },
|
||||
* uniqueConstraints={
|
||||
* @ORM\UniqueConstraint(name="EC_name_idx", columns={"name"})
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class ErrorCategory implements JsonSerializable
|
||||
{
|
||||
|
||||
const TYPE_MACHINERY = 'machinery';
|
||||
const TYPE_ELECTRIC = 'electric';
|
||||
const TYPE_BUILDING = 'building';
|
||||
const TYPE_OTHER = 'other';
|
||||
|
||||
private $typeMap = [
|
||||
self::TYPE_MACHINERY => 'gépész',
|
||||
self::TYPE_ELECTRIC => 'elektromos',
|
||||
self::TYPE_BUILDING => 'építész',
|
||||
self::TYPE_OTHER => 'egyéb',
|
||||
];
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="IDENTITY")
|
||||
* @var int
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="name", type="string", length=250, nullable=false)
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="type", type="string", length=10, nullable=false)
|
||||
* @var string
|
||||
*/
|
||||
private $type;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="active", type="boolean", options={"default": true})
|
||||
* @var bool
|
||||
*/
|
||||
private $active = true;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return ErrorCategory
|
||||
*/
|
||||
public function setId(int $id): ErrorCategory
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return ErrorCategory
|
||||
*/
|
||||
public function setName(string $name): ErrorCategory
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getType(): string
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getMappedType(): string
|
||||
{
|
||||
return $this->typeMap[$this->getType()];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $type
|
||||
* @return ErrorCategory
|
||||
*/
|
||||
public function setType(string $type): ErrorCategory
|
||||
{
|
||||
$this->type = $type;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function getActive(): bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $active
|
||||
* @return ErrorCategory
|
||||
*/
|
||||
public function setActive(bool $active): ErrorCategory
|
||||
{
|
||||
$this->active = $active;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'type' => $this->type,
|
||||
'active' => $this->active,
|
||||
];
|
||||
}
|
||||
}
|
||||
134
src/App/Entity/ErrorOrigin.php
Normal file
134
src/App/Entity/ErrorOrigin.php
Normal file
@@ -0,0 +1,134 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="error_origins",
|
||||
* indexes={
|
||||
* @ORM\Index(name="EO_active_idx", columns={"active"})
|
||||
* },
|
||||
* uniqueConstraints={
|
||||
* @ORM\UniqueConstraint(name="EO_name_idx", columns={"name"}),
|
||||
* @ORM\UniqueConstraint(name="EO_code_idx", columns={"code"})
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class ErrorOrigin implements JsonSerializable
|
||||
{
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="IDENTITY")
|
||||
* @var int
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="code", type="string", length=1)
|
||||
* @var string
|
||||
*/
|
||||
private $code;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="name", type="string", length=150, nullable=false)
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="active", type="boolean", options={"default": true})
|
||||
* @var bool
|
||||
*/
|
||||
private $active = true;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return ErrorOrigin
|
||||
*/
|
||||
public function setId(int $id)
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCode(): string
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @return ErrorOrigin
|
||||
*/
|
||||
public function setCode(string $code): ErrorOrigin
|
||||
{
|
||||
$this->code = $code;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return ErrorOrigin
|
||||
*/
|
||||
public function setName(string $name): ErrorOrigin
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function getActive(): bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $active
|
||||
* @return ErrorOrigin
|
||||
*/
|
||||
public function setActive(bool $active): ErrorOrigin
|
||||
{
|
||||
$this->active = $active;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'code' => $this->code,
|
||||
'name' => $this->name,
|
||||
'active' => $this->active,
|
||||
];
|
||||
}
|
||||
}
|
||||
224
src/App/Entity/FacilityLocation.php
Normal file
224
src/App/Entity/FacilityLocation.php
Normal file
@@ -0,0 +1,224 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Gedmo\Mapping\Annotation as Gedmo;
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* @Gedmo\Tree(type="closure")
|
||||
* @Gedmo\TreeClosure(class="App\Entity\FacilityLocationClosure")
|
||||
* @ORM\Entity(repositoryClass="Gedmo\Tree\Entity\Repository\ClosureTreeRepository")
|
||||
* @ORM\Table(
|
||||
* name="facility_locations",
|
||||
* indexes={
|
||||
* @ORM\Index(name="FL_active_idx", columns={"active"}),
|
||||
* @ORM\Index(name="FL_name_idx", columns={"name"})
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class FacilityLocation implements JsonSerializable
|
||||
{
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="IDENTITY")
|
||||
* @var int
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="room_number", type="string", length=10, nullable=false)
|
||||
* @var string
|
||||
*/
|
||||
private $roomNumber;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="name", type="string", length=250, nullable=false)
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="size", type="float", nullable=false)
|
||||
* @var float
|
||||
*/
|
||||
private $size;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="integer", nullable=true)
|
||||
* @Gedmo\TreeLevel
|
||||
* @var int
|
||||
*/
|
||||
private $level;
|
||||
|
||||
/**
|
||||
* @Gedmo\TreeParent
|
||||
* @ORM\JoinColumn(referencedColumnName="id", onDelete="CASCADE")
|
||||
* @ORM\ManyToOne(targetEntity="FacilityLocation", inversedBy="children")
|
||||
* @var FacilityLocation
|
||||
*/
|
||||
private $parent;
|
||||
|
||||
/**
|
||||
* @var FacilityLocationClosure[]
|
||||
*/
|
||||
private $closures = [];
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="active", type="boolean", options={"default": true})
|
||||
* @var bool
|
||||
*/
|
||||
private $active = true;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return FacilityLocation
|
||||
*/
|
||||
public function setId(int $id): FacilityLocation
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getRoomNumber(): string
|
||||
{
|
||||
return $this->roomNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $roomNumber
|
||||
* @return FacilityLocation
|
||||
*/
|
||||
public function setRoomNumber(string $roomNumber): FacilityLocation
|
||||
{
|
||||
$this->roomNumber = $roomNumber;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return FacilityLocation
|
||||
*/
|
||||
public function setName(string $name): FacilityLocation
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getSize(): float
|
||||
{
|
||||
return $this->size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $size
|
||||
* @return FacilityLocation
|
||||
*/
|
||||
public function setSize(float $size): FacilityLocation
|
||||
{
|
||||
$this->size = $size;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLevel()
|
||||
{
|
||||
return $this->level;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $level
|
||||
* @return FacilityLocation
|
||||
*/
|
||||
public function setLevel($level)
|
||||
{
|
||||
$this->level = $level;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $parent
|
||||
* @return FacilityLocation
|
||||
*/
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FacilityLocationClosure $closure
|
||||
*/
|
||||
public function addClosure(FacilityLocationClosure $closure)
|
||||
{
|
||||
$this->closures[] = $closure;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function getActive(): bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $active
|
||||
* @return FacilityLocation
|
||||
*/
|
||||
public function setActive(bool $active): FacilityLocation
|
||||
{
|
||||
$this->active = $active;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'roomNumber' => $this->getRoomNumber(),
|
||||
'name' => $this->getName(),
|
||||
'size' => $this->getSize(),
|
||||
'level' => $this->getLevel(),
|
||||
'active' => $this->getActive(),
|
||||
];
|
||||
}
|
||||
}
|
||||
15
src/App/Entity/FacilityLocationClosure.php
Normal file
15
src/App/Entity/FacilityLocationClosure.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Gedmo\Tree\Entity\MappedSuperclass\AbstractClosure;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="facility_locations__closure")
|
||||
*/
|
||||
class FacilityLocationClosure extends AbstractClosure
|
||||
{
|
||||
|
||||
}
|
||||
940
src/App/Entity/Fault.php
Normal file
940
src/App/Entity/Fault.php
Normal file
@@ -0,0 +1,940 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Gedmo\Mapping\Annotation as Gedmo;
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="fault",
|
||||
* indexes={
|
||||
* @ORM\Index(name="F_facilityloc_idx", columns={"facility_location_id"}),
|
||||
* @ORM\Index(name="F_errorcat_idx", columns={"error_category_id"}),
|
||||
* @ORM\Index(name="F_errororig_idx", columns={"error_origin_id"}),
|
||||
* @ORM\Index(name="F_soltimeinterval_idx", columns={"solution_time_interval_id"})
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class Fault implements JsonSerializable
|
||||
{
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="IDENTITY")
|
||||
* @var int
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="worksheet_number", type="string", length=30, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $worksheetNumber;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="facility_location_id", nullable=false)
|
||||
* @ORM\ManyToOne(targetEntity="FacilityLocation", inversedBy="faults")
|
||||
* @var FacilityLocation
|
||||
*/
|
||||
private $facilityLocation;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="facility_location_description", type="text", length=65535, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $facilityLocationDescription;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="error_category_id", nullable=false)
|
||||
* @ORM\ManyToOne(targetEntity="ErrorCategory", inversedBy="faults")
|
||||
* @var ErrorCategory
|
||||
*/
|
||||
private $errorCategory;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="error_origin_id", nullable=false)
|
||||
* @ORM\ManyToOne(targetEntity="ErrorOrigin", inversedBy="faults")
|
||||
* @var ErrorOrigin
|
||||
*/
|
||||
private $errorOrigin;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="error_description", type="text", length=65535, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $errorDescription;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="solution_time_interval_id", nullable=false)
|
||||
* @ORM\ManyToOne(targetEntity="SolutionTimeInterval", inversedBy="faults")
|
||||
* @var SolutionTimeInterval
|
||||
*/
|
||||
private $solutionTimeInterval;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="solution_time_interval_other", type="text", length=65535, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $solutionTimeIntervalOther;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="state", type="string", length=15, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $state = "new";
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Attachment", mappedBy="fault")
|
||||
* @var Attachment[]
|
||||
*/
|
||||
private $attachments;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="reporter_id", nullable=true)
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="reportedFaults")
|
||||
* @var User
|
||||
*/
|
||||
private $reporter;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="worker_id", nullable=true)
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="workingOnFaults")
|
||||
* @var User
|
||||
*/
|
||||
private $worker;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="confirmer_id", nullable=true)
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="confirmedFaults")
|
||||
* @var User
|
||||
*/
|
||||
private $confirmer;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="confirmed_at", type="datetime", nullable=true)
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $confirmedAt;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="acknowledger_id", nullable=true)
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="acknowledgedFaults")
|
||||
* @var User
|
||||
*/
|
||||
private $acknowledgedBy;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="acknowledged_at", type="datetime", nullable=true)
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $acknowledgedAt;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="approver_id", nullable=true)
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="approvedFaults")
|
||||
* @var User
|
||||
*/
|
||||
private $approvedBy;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="approved_at", type="datetime", nullable=true)
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $approvedAt;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="report_accepted", type="datetime", nullable=true)
|
||||
* @var \DateTime
|
||||
* @todo possibly unused
|
||||
*/
|
||||
private $reportAccepted;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="work_started", type="datetime", nullable=true)
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $workStarted;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="work_finished", type="datetime", nullable=true)
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $workFinished;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="time_spent", type="float", nullable=true)
|
||||
* @var float
|
||||
*/
|
||||
private $timeSpent;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="work_cost_estimate", type="integer", nullable=true)
|
||||
* @var int
|
||||
*/
|
||||
private $workCostEstimate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="material_cost_estimate", type="integer", nullable=true)
|
||||
* @var int
|
||||
*/
|
||||
private $materialCostEstimate;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="used_materials", type="array", length=65535, nullable=true)
|
||||
* @var mixed
|
||||
*/
|
||||
private $usedMaterials;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="work_done", type="array", length=65535, nullable=true)
|
||||
* @var mixed
|
||||
*/
|
||||
private $workDone;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="created_at", type="datetime", nullable=true)
|
||||
* @Gedmo\Timestampable(on="create")
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="FaultSnapshot", mappedBy="fault")
|
||||
* @var FaultSnapshot[]
|
||||
*/
|
||||
private $snapshots;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="FaultComment", mappedBy="fault")
|
||||
* @var FaultComment[]
|
||||
*/
|
||||
private $comments;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="must_lower_cost", type="boolean", options={"default": false})
|
||||
* @var bool
|
||||
*/
|
||||
private $mustLowerCost = false;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="allocated_expense", type="integer", options={"default": 0})
|
||||
* @var int
|
||||
*/
|
||||
private $allocatedExpense = 0;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->attachments = new ArrayCollection();
|
||||
$this->snapshots = new ArrayCollection();
|
||||
$this->comments = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return Fault
|
||||
*/
|
||||
public function setId(int $id): Fault
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getWorksheetNumber(): ?string
|
||||
{
|
||||
return $this->worksheetNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $worksheetNumber
|
||||
* @return Fault
|
||||
*/
|
||||
public function setWorksheetNumber(?string $worksheetNumber): Fault
|
||||
{
|
||||
$this->worksheetNumber = $worksheetNumber;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FacilityLocation
|
||||
*/
|
||||
public function getFacilityLocation(): FacilityLocation
|
||||
{
|
||||
return $this->facilityLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FacilityLocation $facilityLocation
|
||||
* @return Fault
|
||||
*/
|
||||
public function setFacilityLocation(FacilityLocation $facilityLocation): Fault
|
||||
{
|
||||
$this->facilityLocation = $facilityLocation;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFacilityLocationDescription()
|
||||
{
|
||||
return $this->facilityLocationDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $facilityLocationDescription
|
||||
* @return Fault
|
||||
*/
|
||||
public function setFacilityLocationDescription(string $facilityLocationDescription): Fault
|
||||
{
|
||||
$this->facilityLocationDescription = $facilityLocationDescription;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ErrorCategory
|
||||
*/
|
||||
public function getErrorCategory(): ErrorCategory
|
||||
{
|
||||
return $this->errorCategory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ErrorCategory $errorCategory
|
||||
* @return Fault
|
||||
*/
|
||||
public function setErrorCategory(ErrorCategory $errorCategory): Fault
|
||||
{
|
||||
$this->errorCategory = $errorCategory;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ErrorOrigin
|
||||
*/
|
||||
public function getErrorOrigin(): ErrorOrigin
|
||||
{
|
||||
return $this->errorOrigin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ErrorOrigin $errorOrigin
|
||||
* @return Fault
|
||||
*/
|
||||
public function setErrorOrigin(ErrorOrigin $errorOrigin): Fault
|
||||
{
|
||||
$this->errorOrigin = $errorOrigin;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getErrorDescription()
|
||||
{
|
||||
return $this->errorDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $errorDescription
|
||||
* @return Fault
|
||||
*/
|
||||
public function setErrorDescription(string $errorDescription): Fault
|
||||
{
|
||||
$this->errorDescription = $errorDescription;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SolutionTimeInterval
|
||||
*/
|
||||
public function getSolutionTimeInterval(): SolutionTimeInterval
|
||||
{
|
||||
return $this->solutionTimeInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SolutionTimeInterval $solutionTimeInterval
|
||||
* @return Fault
|
||||
*/
|
||||
public function setSolutionTimeInterval(SolutionTimeInterval $solutionTimeInterval): Fault
|
||||
{
|
||||
$this->solutionTimeInterval = $solutionTimeInterval;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSolutionTimeIntervalOther()
|
||||
{
|
||||
return $this->solutionTimeIntervalOther;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $solutionTimeIntervalOther
|
||||
* @return Fault
|
||||
*/
|
||||
public function setSolutionTimeIntervalOther(string $solutionTimeIntervalOther): Fault
|
||||
{
|
||||
$this->solutionTimeIntervalOther = $solutionTimeIntervalOther;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getState(): string
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $state
|
||||
* @return Fault
|
||||
*/
|
||||
public function setState(string $state): Fault
|
||||
{
|
||||
$this->state = $state;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection
|
||||
*/
|
||||
public function getAttachments()
|
||||
{
|
||||
return $this->attachments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Attachment $attachment
|
||||
* @return Fault
|
||||
*/
|
||||
public function addAttachment(Attachment $attachment): Fault
|
||||
{
|
||||
$this->attachments->add($attachment);
|
||||
$attachment->setFault($this);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addAttachments(Collection $attachments): Fault
|
||||
{
|
||||
foreach ($attachments as $attachment) {
|
||||
$this->addAttachment($attachment);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Attachment $attachment
|
||||
* @return Fault
|
||||
*/
|
||||
public function removeAttachment(Attachment $attachment): Fault
|
||||
{
|
||||
$this->attachments->removeElement($attachment);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeAttachments(Collection $attachments): Fault
|
||||
{
|
||||
foreach ($attachments as $attachment) {
|
||||
$this->removeAttachment($attachment);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getReporter()
|
||||
{
|
||||
return $this->reporter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $reporter
|
||||
* @return Fault
|
||||
*/
|
||||
public function setReporter(User $reporter)
|
||||
{
|
||||
$this->reporter = $reporter;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getWorker()
|
||||
{
|
||||
return $this->worker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $worker
|
||||
* @return Fault
|
||||
*/
|
||||
public function setWorker($worker)
|
||||
{
|
||||
$this->worker = $worker;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getConfirmer(): ?User
|
||||
{
|
||||
return $this->confirmer;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $confirmer
|
||||
* @return Fault
|
||||
*/
|
||||
public function setConfirmer(?User $confirmer): Fault
|
||||
{
|
||||
$this->confirmer = $confirmer;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getConfirmedAt(): ?\DateTime
|
||||
{
|
||||
return $this->confirmedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $confirmedAt
|
||||
* @return Fault
|
||||
*/
|
||||
public function setConfirmedAt(?\DateTime $confirmedAt): Fault
|
||||
{
|
||||
$this->confirmedAt = $confirmedAt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getAcknowledgedBy(): ?User
|
||||
{
|
||||
return $this->acknowledgedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $acknowledgedBy
|
||||
* @return Fault
|
||||
*/
|
||||
public function setAcknowledgedBy(?User $acknowledgedBy): Fault
|
||||
{
|
||||
$this->acknowledgedBy = $acknowledgedBy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getAcknowledgedAt(): ?\DateTime
|
||||
{
|
||||
return $this->acknowledgedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $acknowledgedAt
|
||||
* @return Fault
|
||||
*/
|
||||
public function setAcknowledgedAt(?\DateTime $acknowledgedAt): Fault
|
||||
{
|
||||
$this->acknowledgedAt = $acknowledgedAt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getApprovedBy(): ?User
|
||||
{
|
||||
return $this->approvedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $approvedBy
|
||||
* @return Fault
|
||||
*/
|
||||
public function setApprovedBy(?User $approvedBy): Fault
|
||||
{
|
||||
$this->approvedBy = $approvedBy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getApprovedAt(): ?\DateTime
|
||||
{
|
||||
return $this->approvedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $approvedAt
|
||||
* @return Fault
|
||||
*/
|
||||
public function setApprovedAt(?\DateTime $approvedAt): Fault
|
||||
{
|
||||
$this->approvedAt = $approvedAt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getReportAccepted(): ?\DateTime
|
||||
{
|
||||
return $this->reportAccepted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $reportAccepted
|
||||
* @return Fault
|
||||
*/
|
||||
public function setReportAccepted(?\DateTime $reportAccepted): Fault
|
||||
{
|
||||
$this->reportAccepted = $reportAccepted;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getWorkStarted()
|
||||
{
|
||||
return $this->workStarted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $workStarted
|
||||
* @return Fault
|
||||
*/
|
||||
public function setWorkStarted(\DateTime $workStarted): Fault
|
||||
{
|
||||
$this->workStarted = $workStarted;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getWorkFinished()
|
||||
{
|
||||
return $this->workFinished;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $workFinished
|
||||
* @return Fault
|
||||
*/
|
||||
public function setWorkFinished(\DateTime $workFinished): Fault
|
||||
{
|
||||
$this->workFinished = $workFinished;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getTimeSpent(): ?float
|
||||
{
|
||||
return $this->timeSpent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $timeSpent
|
||||
* @return Fault
|
||||
*/
|
||||
public function setTimeSpent(?float $timeSpent): Fault
|
||||
{
|
||||
$this->timeSpent = $timeSpent;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getWorkCostEstimate(): ?int
|
||||
{
|
||||
return $this->workCostEstimate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $workCostEstimate
|
||||
* @return Fault
|
||||
*/
|
||||
public function setWorkCostEstimate(?int $workCostEstimate): Fault
|
||||
{
|
||||
$this->workCostEstimate = $workCostEstimate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMaterialCostEstimate(): ?int
|
||||
{
|
||||
return $this->materialCostEstimate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $materialCostEstimate
|
||||
* @return Fault
|
||||
*/
|
||||
public function setMaterialCostEstimate(?int $materialCostEstimate): Fault
|
||||
{
|
||||
$this->materialCostEstimate = $materialCostEstimate;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUsedMaterials()
|
||||
{
|
||||
return $this->usedMaterials;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $usedMaterials
|
||||
* @return Fault
|
||||
*/
|
||||
public function setUsedMaterials($usedMaterials)
|
||||
{
|
||||
$this->usedMaterials = $usedMaterials;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getWorkDone()
|
||||
{
|
||||
return $this->workDone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $workDone
|
||||
* @return Fault
|
||||
*/
|
||||
public function setWorkDone($workDone)
|
||||
{
|
||||
$this->workDone = $workDone;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getCreatedAt()
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $createdAt
|
||||
* @return Fault
|
||||
*/
|
||||
public function setCreatedAt(\DateTime $createdAt): Fault
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ArrayCollection
|
||||
*/
|
||||
public function getSnapshots()
|
||||
{
|
||||
return $this->snapshots;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return ArrayCollection
|
||||
*/
|
||||
public function getComments()
|
||||
{
|
||||
return $this->comments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FaultComment $comment
|
||||
* @return Fault
|
||||
*/
|
||||
public function addComment(FaultComment $comment): Fault
|
||||
{
|
||||
if (!$this->comments->contains($comment)) {
|
||||
$this->comments->add($comment);
|
||||
$comment->setFault($this);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function addComments(Collection $comments): Fault
|
||||
{
|
||||
foreach ($comments as $comment) {
|
||||
$this->addComment($comment);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FaultComment $comment
|
||||
* @return Fault
|
||||
*/
|
||||
public function removeComment(FaultComment $comment): Fault
|
||||
{
|
||||
if ($this->comments->contains($comment)) {
|
||||
$this->comments->removeElement($comment);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function removeComments(Collection $comments): Fault
|
||||
{
|
||||
foreach ($comments as $comment) {
|
||||
$this->removeComment($comment);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isMustLowerCost(): ?bool
|
||||
{
|
||||
return $this->mustLowerCost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $mustLowerCost
|
||||
* @return Fault
|
||||
*/
|
||||
public function setMustLowerCost(?bool $mustLowerCost): Fault
|
||||
{
|
||||
$this->mustLowerCost = $mustLowerCost;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getAllocatedExpense(): ?int
|
||||
{
|
||||
return $this->allocatedExpense;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $allocatedExpense
|
||||
* @return Fault
|
||||
*/
|
||||
public function setAllocatedExpense(?int $allocatedExpense): Fault
|
||||
{
|
||||
$this->allocatedExpense = $allocatedExpense;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'facilityLocation' => $this->getFacilityLocation(),
|
||||
'facilityLocationDescription' => $this->getFacilityLocationDescription(),
|
||||
'errorCategory' => $this->getErrorCategory(),
|
||||
'errorOrigin' => $this->getErrorOrigin(),
|
||||
'errorDescription' => $this->getErrorDescription(),
|
||||
'solutionTimeInterval' => $this->getSolutionTimeInterval(),
|
||||
'solutionTimeIntervalOther' => $this->getSolutionTimeIntervalOther(),
|
||||
'state' => $this->getState(),
|
||||
'attachments' => $this->getAttachments()->getValues() ?? [],
|
||||
'worker' => $this->getWorker(),
|
||||
'confirmer' => $this->getConfirmer(),
|
||||
'confirmedAt' => $this->getConfirmedAt(),
|
||||
'acknowledgedBy' => $this->getAcknowledgedBy(),
|
||||
'acknowledgedAt' => $this->getAcknowledgedAt(),
|
||||
'approvedBy' => $this->getApprovedBy(),
|
||||
'approvedAt' => $this->getApprovedAt(),
|
||||
'reportAccepted' => $this->getReportAccepted(),
|
||||
'workStarted' => $this->getWorkStarted(),
|
||||
'workFinished' => $this->getWorkFinished(),
|
||||
'worksheetNumber' => $this->getWorksheetNumber(),
|
||||
'timeSpent' => $this->getTimeSpent(),
|
||||
'workCostEstimate' => $this->getWorkCostEstimate(),
|
||||
'materialCostEstimate' => $this->getMaterialCostEstimate(),
|
||||
'usedMaterials' => $this->getUsedMaterials() ?? [],
|
||||
'workDone' => $this->getWorkDone() ?? [],
|
||||
'createdAt' => $this->getCreatedAt(),
|
||||
'faultSnapshots' => $this->getSnapshots()->toArray() ?? [],
|
||||
'comments' => $this->getComments()->toArray() ?? [],
|
||||
'mustLowerCost' => $this->isMustLowerCost(),
|
||||
'allocatedExpense' => $this->getAllocatedExpense(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getFlatValues()
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'facilityLocation' => $this->getFacilityLocation()->getId(),
|
||||
'facilityLocationDescription' => $this->getFacilityLocationDescription(),
|
||||
'errorCategory' => $this->getErrorCategory()->getId(),
|
||||
'errorOrigin' => $this->getErrorOrigin()->getId(),
|
||||
'errorDescription' => $this->getErrorDescription(),
|
||||
'solutionTimeInterval' => $this->getSolutionTimeInterval()->getId(),
|
||||
'solutionTimeIntervalOther' => $this->getSolutionTimeIntervalOther(),
|
||||
'state' => $this->getState(),
|
||||
'attachments' => $this->getAttachments()->getValues() ?? [],
|
||||
'worker' => $this->getWorker() ? $this->getWorker()->getId() : null,
|
||||
'confirmer' => $this->getConfirmer() ? $this->getConfirmer()->getId() : null,
|
||||
'confirmedAt' => $this->getConfirmedAt(),
|
||||
'acknowledgedBy' => $this->getAcknowledgedBy() ? $this->getAcknowledgedBy()->getId() : null,
|
||||
'acknowledgedAt' => $this->getAcknowledgedAt(),
|
||||
'approvedBy' => $this->getApprovedBy() ? $this->getApprovedBy()->getId() : null,
|
||||
'approvedAt' => $this->getApprovedAt(),
|
||||
'reportAccepted' => $this->getReportAccepted(),
|
||||
'workStarted' => $this->getWorkStarted(),
|
||||
'workFinished' => $this->getWorkFinished(),
|
||||
'worksheetNumber' => $this->getWorksheetNumber(),
|
||||
'timeSpent' => $this->getTimeSpent(),
|
||||
'workCostEstimate' => $this->getWorkCostEstimate(),
|
||||
'materialCostEstimate' => $this->getMaterialCostEstimate(),
|
||||
'usedMaterials' => $this->getUsedMaterials() ?? [],
|
||||
'workDone' => $this->getWorkDone() ?? [],
|
||||
'createdAt' => $this->getCreatedAt(),
|
||||
'faultSnapshots' => $this->getSnapshots()->toArray() ?? [],
|
||||
'comments' => $this->getComments()->toArray() ?? [],
|
||||
'mustLowerCost' => $this->isMustLowerCost(),
|
||||
'allocatedExpense' => $this->getAllocatedExpense(),
|
||||
];
|
||||
}
|
||||
}
|
||||
164
src/App/Entity/FaultComment.php
Normal file
164
src/App/Entity/FaultComment.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Gedmo\Mapping\Annotation as Gedmo;
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="fault_comments",
|
||||
* indexes={
|
||||
* @ORM\Index(name="FS_created_at", columns={"created_at"})
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class FaultComment implements JsonSerializable
|
||||
{
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="IDENTITY")
|
||||
* @var int
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="fault_id", nullable=false)
|
||||
* @ORM\ManyToOne(targetEntity="Fault", inversedBy="comments")
|
||||
* @var Fault
|
||||
*/
|
||||
private $fault;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="user_id", nullable=false)
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="faultComments")
|
||||
* @var User
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="comment", type="text", length=65535, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $comment;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="created_at", type="datetime", nullable=true)
|
||||
* @Gedmo\Timestampable(on="create")
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return FaultComment
|
||||
*/
|
||||
public function setId(int $id): FaultComment
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Fault
|
||||
*/
|
||||
public function getFault(): Fault
|
||||
{
|
||||
return $this->fault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Fault $fault
|
||||
* @return FaultComment
|
||||
*/
|
||||
public function setFault(Fault $fault): FaultComment
|
||||
{
|
||||
$this->fault = $fault;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getUser(): User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return FaultComment
|
||||
*/
|
||||
public function setUser(User $user): FaultComment
|
||||
{
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getComment(): string
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $comment
|
||||
* @return FaultComment
|
||||
*/
|
||||
public function setComment(string $comment): FaultComment
|
||||
{
|
||||
$this->comment = $comment;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getCreatedAt(): \DateTime
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $createdAt
|
||||
* @return FaultComment
|
||||
*/
|
||||
public function setCreatedAt(\DateTime $createdAt): FaultComment
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'user' => $this->getUser(),
|
||||
'comment' => $this->getComment(),
|
||||
'createdAt' => $this->getCreatedAt(),
|
||||
];
|
||||
}
|
||||
}
|
||||
239
src/App/Entity/FaultSnapshot.php
Normal file
239
src/App/Entity/FaultSnapshot.php
Normal file
@@ -0,0 +1,239 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Gedmo\Mapping\Annotation as Gedmo;
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="fault_snapshot",
|
||||
* indexes={
|
||||
* @ORM\Index(name="FS_oldstate_idx", columns={"old_state"}),
|
||||
* @ORM\Index(name="FS_newstate_idx", columns={"new_state"})
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class FaultSnapshot implements JsonSerializable
|
||||
{
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="IDENTITY")
|
||||
* @var int
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="fault_id", nullable=false)
|
||||
* @ORM\ManyToOne(targetEntity="Fault", inversedBy="snapshots")
|
||||
* @var Fault
|
||||
*/
|
||||
private $fault;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="user_id", nullable=false)
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="faultSnapshots")
|
||||
* @var User
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="old_state", type="string", length=15, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $oldState;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="new_state", type="string", length=15, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $newState;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="payload", type="json", length=65535, nullable=true)
|
||||
* @var mixed
|
||||
*/
|
||||
private $payload;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="comment", type="text", length=65535, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $comment;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="created_at", type="datetime", nullable=true)
|
||||
* @Gedmo\Timestampable(on="create")
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $createdAt;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return FaultSnapshot
|
||||
*/
|
||||
public function setId(int $id): FaultSnapshot
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Fault
|
||||
*/
|
||||
public function getFault(): Fault
|
||||
{
|
||||
return $this->fault;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Fault $fault
|
||||
* @return FaultSnapshot
|
||||
*/
|
||||
public function setFault(Fault $fault): FaultSnapshot
|
||||
{
|
||||
$this->fault = $fault;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getUser(): User
|
||||
{
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $user
|
||||
* @return FaultSnapshot
|
||||
*/
|
||||
public function setUser(User $user): FaultSnapshot
|
||||
{
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOldState(): ?string
|
||||
{
|
||||
return $this->oldState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $oldState
|
||||
* @return FaultSnapshot
|
||||
*/
|
||||
public function setOldState(string $oldState): FaultSnapshot
|
||||
{
|
||||
$this->oldState = $oldState;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getNewState(): ?string
|
||||
{
|
||||
return $this->newState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $newState
|
||||
* @return FaultSnapshot
|
||||
*/
|
||||
public function setNewState(string $newState): FaultSnapshot
|
||||
{
|
||||
$this->newState = $newState;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPayload()
|
||||
{
|
||||
return $this->payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $payload
|
||||
* @return FaultSnapshot
|
||||
*/
|
||||
public function setPayload($payload)
|
||||
{
|
||||
$this->payload = $payload;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getComment(): ?string
|
||||
{
|
||||
return $this->comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $comment
|
||||
* @return FaultSnapshot
|
||||
*/
|
||||
public function setComment(string $comment): FaultSnapshot
|
||||
{
|
||||
$this->comment = $comment;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCreatedAt(): ?\DateTime
|
||||
{
|
||||
return $this->createdAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $createdAt
|
||||
* @return FaultSnapshot
|
||||
*/
|
||||
public function setCreatedAt(\DateTime $createdAt)
|
||||
{
|
||||
$this->createdAt = $createdAt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'user' => $this->getUser(),
|
||||
'oldState' => $this->getOldState(),
|
||||
'newState' => $this->getNewState(),
|
||||
'payload' => $this->getPayload(),
|
||||
'comment' => $this->getComment(),
|
||||
'createdAt' => $this->getCreatedAt(),
|
||||
];
|
||||
}
|
||||
}
|
||||
649
src/App/Entity/Maintenance.php
Normal file
649
src/App/Entity/Maintenance.php
Normal file
@@ -0,0 +1,649 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Gedmo\Mapping\Annotation as Gedmo;
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="maintenance"
|
||||
* )
|
||||
*/
|
||||
class Maintenance implements JsonSerializable
|
||||
{
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="hash", type="string", length=250, nullable=false)
|
||||
* @var string
|
||||
*/
|
||||
private $hash;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="old_hash", type="string", length=250)
|
||||
* @var string
|
||||
*/
|
||||
private $oldHash;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="device_name", type="string", length=250, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $deviceName;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="component_name", type="string", length=250, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $componentName;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="responsible", type="string", length=250, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $responsible;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="work_description", type="text", length=5000, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $workDescription;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="device_count", type="integer")
|
||||
* @var int
|
||||
*/
|
||||
private $count;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="work_year", type="integer")
|
||||
* @var int
|
||||
*/
|
||||
private $year;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="work_month", type="integer")
|
||||
* @var int
|
||||
*/
|
||||
private $month;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="work_week", type="integer")
|
||||
* @var int
|
||||
*/
|
||||
private $week;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="worker_count", type="integer")
|
||||
* @var int
|
||||
*/
|
||||
private $workerCount;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="time_cost", type="float")
|
||||
* @var float
|
||||
*/
|
||||
private $timeCost;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="should_start_at", type="datetime", nullable=true)
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $shouldStartAt;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="should_be_done_by", type="datetime", nullable=true)
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $shouldBeDoneBy;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="state", type="string", length=15, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $state = "new";
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="worksheet_number", type="string", length=30, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $worksheetNumber;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="worker_id", nullable=true)
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="workingOnMaintenances")
|
||||
* @var User
|
||||
*/
|
||||
private $worker;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="approver_id", nullable=true)
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="approvedMaintenances")
|
||||
* @var User
|
||||
*/
|
||||
private $approvedBy;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="approved_at", type="datetime", nullable=true)
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $approvedAt;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="work_started", type="datetime", nullable=true)
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $workStarted;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="started_by", nullable=true)
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="startedMaintenances")
|
||||
* @var User
|
||||
*/
|
||||
private $startedBy;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="work_finished", type="datetime", nullable=true)
|
||||
* @var \DateTime
|
||||
*/
|
||||
private $workFinished;
|
||||
|
||||
/**
|
||||
* @ORM\JoinColumn(name="finished_by", nullable=true)
|
||||
* @ORM\ManyToOne(targetEntity="User", inversedBy="finishedMaintenances")
|
||||
* @var User
|
||||
*/
|
||||
private $finishedBy;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHash(): string
|
||||
{
|
||||
return $this->hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $hash
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setHash(string $hash): Maintenance
|
||||
{
|
||||
$this->hash = $hash;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getOldHash(): string
|
||||
{
|
||||
return $this->oldHash;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $oldHash
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setOldHash(string $oldHash): Maintenance
|
||||
{
|
||||
$this->oldHash = $oldHash;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDeviceName(): string
|
||||
{
|
||||
return $this->deviceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $deviceName
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setDeviceName(string $deviceName): Maintenance
|
||||
{
|
||||
$this->deviceName = $deviceName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getComponentName(): string
|
||||
{
|
||||
return $this->componentName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $componentName
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setComponentName(string $componentName): Maintenance
|
||||
{
|
||||
$this->componentName = $componentName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getResponsible(): string
|
||||
{
|
||||
return $this->responsible;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $responsible
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setResponsible(string $responsible): Maintenance
|
||||
{
|
||||
$this->responsible = $responsible;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getWorkDescription(): string
|
||||
{
|
||||
return $this->workDescription;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $workDescription
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setWorkDescription(string $workDescription): Maintenance
|
||||
{
|
||||
$this->workDescription = $workDescription;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getCount(): int
|
||||
{
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $count
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setCount(int $count): Maintenance
|
||||
{
|
||||
$this->count = $count;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getYear(): int
|
||||
{
|
||||
return $this->year;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $year
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setYear(int $year): Maintenance
|
||||
{
|
||||
$this->year = $year;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getMonth(): int
|
||||
{
|
||||
return $this->month;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $month
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setMonth(int $month): Maintenance
|
||||
{
|
||||
$this->month = $month;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getWeek(): int
|
||||
{
|
||||
return $this->week;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $week
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setWeek(int $week): Maintenance
|
||||
{
|
||||
$this->week = $week;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getWorkerCount(): int
|
||||
{
|
||||
return $this->workerCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $workerCount
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setWorkerCount(int $workerCount): Maintenance
|
||||
{
|
||||
$this->workerCount = $workerCount;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return float
|
||||
*/
|
||||
public function getTimeCost(): float
|
||||
{
|
||||
return $this->timeCost;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param float $timeCost
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setTimeCost(float $timeCost): Maintenance
|
||||
{
|
||||
$this->timeCost = $timeCost;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getShouldStartAt(): \DateTime
|
||||
{
|
||||
return $this->shouldStartAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $shouldStartAt
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setShouldStartAt(\DateTime $shouldStartAt): Maintenance
|
||||
{
|
||||
$this->shouldStartAt = $shouldStartAt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getShouldBeDoneBy(): \DateTime
|
||||
{
|
||||
return $this->shouldBeDoneBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $shouldBeDoneBy
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setShouldBeDoneBy(\DateTime $shouldBeDoneBy): Maintenance
|
||||
{
|
||||
$this->shouldBeDoneBy = $shouldBeDoneBy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getWorksheetNumber(): ?string
|
||||
{
|
||||
return $this->worksheetNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $worksheetNumber
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setWorksheetNumber(?string $worksheetNumber): Maintenance
|
||||
{
|
||||
$this->worksheetNumber = $worksheetNumber;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getState(): string
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $state
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setState(string $state): Maintenance
|
||||
{
|
||||
$this->state = $state;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getWorker()
|
||||
{
|
||||
return $this->worker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $worker
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setWorker($worker): Maintenance
|
||||
{
|
||||
$this->worker = $worker;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getApprovedBy(): ?User
|
||||
{
|
||||
return $this->approvedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $approvedBy
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setApprovedBy(?User $approvedBy): Maintenance
|
||||
{
|
||||
$this->approvedBy = $approvedBy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getApprovedAt(): ?\DateTime
|
||||
{
|
||||
return $this->approvedAt;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $approvedAt
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setApprovedAt(?\DateTime $approvedAt): Maintenance
|
||||
{
|
||||
$this->approvedAt = $approvedAt;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getWorkStarted(): ?\DateTime
|
||||
{
|
||||
return $this->workStarted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $workStarted
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setWorkStarted(?\DateTime $workStarted): Maintenance
|
||||
{
|
||||
$this->workStarted = $workStarted;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getStartedBy(): ?User
|
||||
{
|
||||
return $this->startedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $startedBy
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setStartedBy(User $startedBy): Maintenance
|
||||
{
|
||||
$this->startedBy = $startedBy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getWorkFinished(): ?\DateTime
|
||||
{
|
||||
return $this->workFinished;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \DateTime $workFinished
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setWorkFinished(?\DateTime $workFinished): Maintenance
|
||||
{
|
||||
$this->workFinished = $workFinished;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User
|
||||
*/
|
||||
public function getFinishedBy(): ?User
|
||||
{
|
||||
return $this->finishedBy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param User $finishedBy
|
||||
* @return Maintenance
|
||||
*/
|
||||
public function setFinishedBy(User $finishedBy): Maintenance
|
||||
{
|
||||
$this->finishedBy = $finishedBy;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
$formatString = "Y-m-d H:i";
|
||||
return [
|
||||
'hash' => $this->getHash(),
|
||||
'deviceName' => $this->getDeviceName(),
|
||||
'componentName' => $this->getComponentName(),
|
||||
'responsible' => $this->getResponsible(),
|
||||
'workDescription' => $this->getWorkDescription(),
|
||||
'count' => $this->getCount(),
|
||||
'year' => $this->getYear(),
|
||||
'month' => $this->getMonth(),
|
||||
'week' => $this->getWeek(),
|
||||
'workerCount' => $this->getWorkerCount(),
|
||||
'timeCost' => $this->getTimeCost(),
|
||||
'shouldStartAt' => $this->getShouldStartAt()
|
||||
? $this->getShouldStartAt()->format($formatString) : null,
|
||||
'shouldBeDoneBy' => $this->getShouldBeDoneBy()
|
||||
? $this->getShouldBeDoneBy()->format($formatString) : null,
|
||||
'state' => $this->getState(),
|
||||
'worker' => $this->getWorker(),
|
||||
'approvedBy' => $this->getApprovedBy(),
|
||||
'approvedAt' => $this->getApprovedAt()
|
||||
? $this->getApprovedAt()->format($formatString) : null,
|
||||
'workStarted' => $this->getWorkStarted()
|
||||
? $this->getWorkStarted()->format($formatString) : null,
|
||||
'staretedBy' => $this->getStartedBy(),
|
||||
'workFinished' => $this->getWorkFinished()
|
||||
? $this->getWorkFinished()->format($formatString) : null,
|
||||
'finishedBy' => $this->getFinishedBy(),
|
||||
'worksheetNumber' => $this->getWorksheetNumber(),
|
||||
];
|
||||
}
|
||||
|
||||
public function getFlatValues()
|
||||
{
|
||||
$formatString = "Y-m-d H:i";
|
||||
return [
|
||||
'hash' => $this->getHash(),
|
||||
'deviceName' => $this->getDeviceName(),
|
||||
'componentName' => $this->getComponentName(),
|
||||
'responsible' => $this->getResponsible(),
|
||||
'workDescription' => $this->getWorkDescription(),
|
||||
'count' => $this->getCount(),
|
||||
'year' => $this->getYear(),
|
||||
'month' => $this->getMonth(),
|
||||
'week' => $this->getWeek(),
|
||||
'workerCount' => $this->getWorkerCount(),
|
||||
'timeCost' => $this->getTimeCost(),
|
||||
'shouldStartAt' => $this->getShouldStartAt()
|
||||
? $this->getShouldStartAt()->format($formatString) : null,
|
||||
'shouldBeDoneBy' => $this->getShouldBeDoneBy()
|
||||
? $this->getShouldBeDoneBy()->format($formatString) : null,
|
||||
'state' => $this->getState(),
|
||||
'worker' => $this->getWorker() ? $this->getWorker()->getId() : null,
|
||||
'approvedBy' => $this->getApprovedBy() ? $this->getApprovedBy()->getId() : null,
|
||||
'approvedAt' => $this->getApprovedAt()
|
||||
? $this->getApprovedAt()->format($formatString) : null,
|
||||
'workStarted' => $this->getWorkStarted()
|
||||
? $this->getWorkStarted()->format($formatString) : null,
|
||||
'staretedBy' => $this->getStartedBy(),
|
||||
'workFinished' => $this->getWorkFinished()
|
||||
? $this->getWorkFinished()->format($formatString) : null,
|
||||
'finishedBy' => $this->getFinishedBy(),
|
||||
'worksheetNumber' => $this->getWorksheetNumber(),
|
||||
];
|
||||
}
|
||||
}
|
||||
133
src/App/Entity/SolutionTimeInterval.php
Normal file
133
src/App/Entity/SolutionTimeInterval.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="solution_time_intervals",
|
||||
* indexes={
|
||||
* @ORM\Index(name="ST_active_idx", columns={"active"})
|
||||
* },
|
||||
* uniqueConstraints={
|
||||
* @ORM\UniqueConstraint(name="ST_name_idx", columns={"name"})
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class SolutionTimeInterval implements JsonSerializable
|
||||
{
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="IDENTITY")
|
||||
* @var int
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="name", type="string", length=150, nullable=false)
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="code", type="string", length=2, nullable=false)
|
||||
* @var string
|
||||
*/
|
||||
private $code;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="active", type="boolean", options={"default": true})
|
||||
* @var bool
|
||||
*/
|
||||
private $active = true;
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return SolutionTimeInterval
|
||||
*/
|
||||
public function setId(int $id): SolutionTimeInterval
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return SolutionTimeInterval
|
||||
*/
|
||||
public function setName(string $name): SolutionTimeInterval
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCode(): string
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $code
|
||||
* @return SolutionTimeInterval
|
||||
*/
|
||||
public function setCode(string $code): SolutionTimeInterval
|
||||
{
|
||||
$this->code = $code;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function getActive(): bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $active
|
||||
* @return SolutionTimeInterval
|
||||
*/
|
||||
public function setActive(bool $active): SolutionTimeInterval
|
||||
{
|
||||
$this->active = $active;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'name' => $this->name,
|
||||
'code' => $this->code,
|
||||
'active' => $this->active,
|
||||
];
|
||||
}
|
||||
}
|
||||
354
src/App/Entity/User.php
Normal file
354
src/App/Entity/User.php
Normal file
@@ -0,0 +1,354 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use JsonSerializable;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="user",
|
||||
* indexes={
|
||||
* @ORM\Index(name="U_search_idx", columns={"name", "email"}),
|
||||
* @ORM\Index(name="U_wants_eml_idx", columns={"wants_email"}),
|
||||
* @ORM\Index(name="U_pwmc_idx", columns={"password_must_change"}),
|
||||
* @ORM\Index(name="U_canpwchng_idx", columns={"can_change_password"}),
|
||||
* @ORM\Index(name="U_active_idx", columns={"active"})
|
||||
* }
|
||||
* )
|
||||
*/
|
||||
class User implements JsonSerializable
|
||||
{
|
||||
|
||||
/**
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="IDENTITY")
|
||||
* @var int
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="name", type="string", length=150, nullable=false)
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="email", type="string", length=150, nullable=false)
|
||||
* @var string
|
||||
*/
|
||||
private $email;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="wants_email", type="boolean", options={"default": true})
|
||||
* @var bool
|
||||
*/
|
||||
private $wantsEmail;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="job", type="string", length=150, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $job;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="phone", type="string", length=20, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $phone;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="password", type="string", length=128, nullable=true)
|
||||
* @var string
|
||||
*/
|
||||
private $password;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="roles", type="simple_array", nullable=true)
|
||||
* @var mixed
|
||||
*/
|
||||
private $roles;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Fault", mappedBy="reporter")
|
||||
* @var Fault[]
|
||||
*/
|
||||
private $reportedFaults;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="password_must_change", type="boolean", options={"default": true})
|
||||
* @var bool
|
||||
*/
|
||||
private $passwordMustChange = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="can_change_password", type="boolean", options={"default": true})
|
||||
* @var bool
|
||||
*/
|
||||
private $canChangePassword = true;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="active", type="boolean", options={"default": true})
|
||||
* @var bool
|
||||
*/
|
||||
private $active = true;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->reportedFaults = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId(): int
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
* @return User
|
||||
*/
|
||||
public function setId(int $id): User
|
||||
{
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName(): string
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return User
|
||||
*/
|
||||
public function setName(string $name): User
|
||||
{
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail()
|
||||
{
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $email
|
||||
* @return User
|
||||
*/
|
||||
public function setEmail(string $email): User
|
||||
{
|
||||
$this->email = $email;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isWantsEmail()
|
||||
{
|
||||
return $this->wantsEmail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $wantsEmail
|
||||
* @return User
|
||||
*/
|
||||
public function setWantsEmail(bool $wantsEmail): User
|
||||
{
|
||||
$this->wantsEmail = $wantsEmail;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getJob(): string
|
||||
{
|
||||
return $this->job;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $job
|
||||
* @return User
|
||||
*/
|
||||
public function setJob(string $job): User
|
||||
{
|
||||
$this->job = $job;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPhone(): string
|
||||
{
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $phone
|
||||
* @return User
|
||||
*/
|
||||
public function setPhone(string $phone): User
|
||||
{
|
||||
$this->phone = $phone;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword(): string
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $password
|
||||
* @return User
|
||||
*/
|
||||
public function setPassword(string $password): User
|
||||
{
|
||||
$this->password = $password;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRoles()
|
||||
{
|
||||
return $this->roles;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $roles
|
||||
* @return User
|
||||
*/
|
||||
public function setRoles($roles)
|
||||
{
|
||||
$this->roles = $roles;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Fault[]|ArrayCollection
|
||||
*/
|
||||
public function getReportedFaults(): ArrayCollection
|
||||
{
|
||||
return $this->reportedFaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Fault $reportedFault
|
||||
* @return User
|
||||
*/
|
||||
public function addReportedFault(Fault $reportedFault): User
|
||||
{
|
||||
if (!$this->reportedFaults->contains($reportedFault)) {
|
||||
$this->reportedFaults->add($reportedFault);
|
||||
$reportedFault->setReporter($this);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Fault $reportedFault
|
||||
* @return User
|
||||
*/
|
||||
public function removeReportedFault(Fault $reportedFault): User
|
||||
{
|
||||
if ($this->reportedFaults->contains($reportedFault)) {
|
||||
$this->reportedFaults->removeElement($reportedFault);
|
||||
$reportedFault->setReporter(null);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function isPasswordMustChange(): bool
|
||||
{
|
||||
return $this->passwordMustChange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $passwordMustChange
|
||||
* @return User
|
||||
*/
|
||||
public function setPasswordMustChange(bool $passwordMustChange): User
|
||||
{
|
||||
$this->passwordMustChange = $passwordMustChange;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getCanChangePassword(): bool
|
||||
{
|
||||
return $this->canChangePassword;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $canChangePassword
|
||||
* @return User
|
||||
*/
|
||||
public function setCanChangePassword(bool $canChangePassword): User
|
||||
{
|
||||
$this->canChangePassword = $canChangePassword;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function getActive(): bool
|
||||
{
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param boolean $active
|
||||
* @return User
|
||||
*/
|
||||
public function setActive(bool $active): User
|
||||
{
|
||||
$this->active = $active;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'id' => $this->getId(),
|
||||
'name' => $this->getName(),
|
||||
'email' => $this->getEmail(),
|
||||
'wantsEmail' => $this->isWantsEmail(),
|
||||
'job' => $this->getJob(),
|
||||
'phone' => $this->getPhone(),
|
||||
'roles' => $this->getRoles(),
|
||||
'passwordMustChange' => $this->isPasswordMustChange(),
|
||||
'canChangePassword' => $this->getCanChangePassword(),
|
||||
'active' => $this->getActive(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user