Added possibility to set project status

This commit is contained in:
Jan Böhmer 2022-12-29 15:22:34 +01:00
parent 5521995f79
commit adc070d10c
7 changed files with 191 additions and 33 deletions

View file

@ -15,6 +15,13 @@ trait ProjectTrait
*/
protected $project_bom_entries = [];
/**
* @var Project|null If a project is set here, then this part is special and represents the builds of a project.
* @ORM\OneToOne(targetEntity="App\Entity\ProjectSystem\Project", inversedBy="build_part")
* @ORM\JoinColumn(nullable=true)
*/
protected ?Project $built_project = null;
/**
* Returns all ProjectBOMEntries that use this part.
* @return Collection<int, ProjectBOMEntry>|ProjectBOMEntry[]
@ -24,6 +31,36 @@ trait ProjectTrait
return $this->project_bom_entries;
}
/**
* Checks whether this part represents the builds of a project
* @return bool True if it represents the builds, false if not
*/
public function isProjectBuildPart(): bool
{
return $this->built_project !== null;
}
/**
* Returns the project that this part represents the builds of, or null if it doesnt
* @return Project|null
*/
public function getBuiltProject(): ?Project
{
return $this->built_project;
}
/**
* Sets the project that this part represents the builds of
* @param Project|null $built_project The project that this part represents the builds of, or null if it is not a build part
*/
public function setBuiltProject(?Project $built_project): self
{
$this->built_project = $built_project;
return $this;
}
/**
* Get all devices which uses this part.
*

View file

@ -25,6 +25,7 @@ namespace App\Entity\ProjectSystem;
use App\Entity\Attachments\ProjectAttachment;
use App\Entity\Base\AbstractStructuralDBElement;
use App\Entity\Parameters\ProjectParameter;
use App\Entity\Parts\Part;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@ -63,6 +64,20 @@ class Project extends AbstractStructuralDBElement
*/
protected int $order_quantity = 0;
/**
* @var string The current status of the project
* @ORM\Column(type="string", length=64)
* @Assert\Choice({"draft","planning","in_production","finished","archived", ""})
*/
protected string $status;
/**
* @var Part|null The (optional) part that represents the builds of this project in the stock
* @ORM\OneToOne(targetEntity="App\Entity\Parts\Part", mappedBy="built_project", cascade={"persist"}, orphanRemoval=true)
*/
protected ?Part $build_part = null;
/**
* @ORM\Column(type="boolean")
*/
@ -219,5 +234,52 @@ class Project extends AbstractStructuralDBElement
return $this;
}
/**
* @return string
*/
public function getStatus(): string
{
return $this->status;
}
/**
* @param string $status
*/
public function setStatus(string $status): void
{
$this->status = $status;
}
/**
* Checks if this project has a associated part representing the builds of this project in the stock.
* @return bool
*/
public function hasBuildPart(): bool
{
return $this->build_part !== null;
}
/**
* Gets the part representing the builds of this project in the stock, if it is existing
* @return Part|null
*/
public function getBuildPart(): ?Part
{
return $this->build_part;
}
/**
* Sets the part representing the builds of this project in the stock.
* @param Part|null $build_part
*/
public function setBuildPart(?Part $build_part): void
{
$this->build_part = $build_part;
if ($build_part) {
$build_part->setBuiltProject($this);
}
}
}