mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
parent
f32ae8bc6c
commit
50cca40f77
9 changed files with 998 additions and 928 deletions
|
@ -20,6 +20,8 @@
|
|||
|
||||
namespace App\Repository\Parts;
|
||||
|
||||
use App\Entity\Parts\Category;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Repository\AbstractPartsContainingRepository;
|
||||
|
||||
class CategoryRepository extends AbstractPartsContainingRepository
|
||||
|
@ -27,11 +29,19 @@ class CategoryRepository extends AbstractPartsContainingRepository
|
|||
|
||||
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
||||
{
|
||||
if (!$element instanceof Category) {
|
||||
throw new \InvalidArgumentException('$element must be an Category!');
|
||||
}
|
||||
|
||||
return $this->getPartsByField($element, $order_by, 'category');
|
||||
}
|
||||
|
||||
public function getPartsCount(object $element): int
|
||||
{
|
||||
if (!$element instanceof Category) {
|
||||
throw new \InvalidArgumentException('$element must be an Category!');
|
||||
}
|
||||
|
||||
return $this->getPartsCountByField($element, 'category');
|
||||
}
|
||||
}
|
|
@ -20,17 +20,27 @@
|
|||
|
||||
namespace App\Repository\Parts;
|
||||
|
||||
use App\Entity\Parts\Footprint;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Repository\AbstractPartsContainingRepository;
|
||||
|
||||
class FootprintRepository extends AbstractPartsContainingRepository
|
||||
{
|
||||
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
||||
{
|
||||
if(!$element instanceof Footprint) {
|
||||
throw new \InvalidArgumentException('$element must be an Footprint!');
|
||||
}
|
||||
|
||||
return $this->getPartsByField($element, $order_by, 'footprint');
|
||||
}
|
||||
|
||||
public function getPartsCount(object $element): int
|
||||
{
|
||||
if(!$element instanceof Footprint) {
|
||||
throw new \InvalidArgumentException('$element must be an Footprint!');
|
||||
}
|
||||
|
||||
return $this->getPartsCountByField($element, 'footprint');
|
||||
}
|
||||
}
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
namespace App\Repository\Parts;
|
||||
|
||||
use App\Entity\Parts\Category;
|
||||
use App\Entity\Parts\Manufacturer;
|
||||
use App\Repository\AbstractPartsContainingRepository;
|
||||
|
||||
class ManufacturerRepository extends AbstractPartsContainingRepository
|
||||
|
@ -27,11 +29,19 @@ class ManufacturerRepository extends AbstractPartsContainingRepository
|
|||
|
||||
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
||||
{
|
||||
if (!$element instanceof Manufacturer) {
|
||||
throw new \InvalidArgumentException('$element must be an Manufacturer!');
|
||||
}
|
||||
|
||||
return $this->getPartsByField($element, $order_by, 'manufacturer');
|
||||
}
|
||||
|
||||
public function getPartsCount(object $element): int
|
||||
{
|
||||
if (!$element instanceof Manufacturer) {
|
||||
throw new \InvalidArgumentException('$element must be an Manufacturer!');
|
||||
}
|
||||
|
||||
return $this->getPartsCountByField($element, 'manufacturer');
|
||||
}
|
||||
}
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
namespace App\Repository\Parts;
|
||||
|
||||
use App\Entity\Parts\Manufacturer;
|
||||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Repository\AbstractPartsContainingRepository;
|
||||
|
||||
class MeasurementUnitRepository extends AbstractPartsContainingRepository
|
||||
|
@ -27,11 +29,19 @@ class MeasurementUnitRepository extends AbstractPartsContainingRepository
|
|||
|
||||
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
||||
{
|
||||
if (!$element instanceof MeasurementUnit) {
|
||||
throw new \InvalidArgumentException('$element must be an MeasurementUnit!');
|
||||
}
|
||||
|
||||
return $this->getPartsByField($element, $order_by, 'partUnit');
|
||||
}
|
||||
|
||||
public function getPartsCount(object $element): int
|
||||
{
|
||||
if (!$element instanceof MeasurementUnit) {
|
||||
throw new \InvalidArgumentException('$element must be an MeasurementUnit!');
|
||||
}
|
||||
|
||||
return $this->getPartsCountByField($element, 'partUnit');
|
||||
}
|
||||
}
|
|
@ -21,13 +21,23 @@
|
|||
namespace App\Repository\Parts;
|
||||
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\PartLot;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Repository\AbstractPartsContainingRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\HttpKernel\HttpCache\Store;
|
||||
|
||||
class StorelocationRepository extends AbstractPartsContainingRepository
|
||||
{
|
||||
/**
|
||||
* @param Storelocation $element
|
||||
*/
|
||||
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
||||
{
|
||||
if(!$element instanceof Storelocation) {
|
||||
throw new \InvalidArgumentException('$element must be an Storelocation!');
|
||||
}
|
||||
|
||||
$qb = new QueryBuilder($this->getEntityManager());
|
||||
|
||||
$qb->select('part')
|
||||
|
@ -45,6 +55,10 @@ class StorelocationRepository extends AbstractPartsContainingRepository
|
|||
|
||||
public function getPartsCount(object $element): int
|
||||
{
|
||||
if(!$element instanceof Storelocation) {
|
||||
throw new \InvalidArgumentException('$element must be an Storelocation!');
|
||||
}
|
||||
|
||||
$qb = new QueryBuilder($this->getEntityManager());
|
||||
|
||||
$qb->select('COUNT(part.id)')
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
namespace App\Repository\Parts;
|
||||
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Entity\Parts\Supplier;
|
||||
use App\Repository\AbstractPartsContainingRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
||||
|
@ -28,6 +30,10 @@ class SupplierRepository extends AbstractPartsContainingRepository
|
|||
{
|
||||
public function getParts(object $element, array $order_by = ['name' => 'ASC']): array
|
||||
{
|
||||
if(!$element instanceof Supplier) {
|
||||
throw new \InvalidArgumentException('$element must be an Supplier!');
|
||||
}
|
||||
|
||||
$qb = new QueryBuilder($this->getEntityManager());
|
||||
|
||||
$qb->select('part')
|
||||
|
@ -45,6 +51,10 @@ class SupplierRepository extends AbstractPartsContainingRepository
|
|||
|
||||
public function getPartsCount(object $element): int
|
||||
{
|
||||
if(!$element instanceof Supplier) {
|
||||
throw new \InvalidArgumentException('$element must be an Supplier!');
|
||||
}
|
||||
|
||||
$qb = new QueryBuilder($this->getEntityManager());
|
||||
|
||||
$qb->select('COUNT(part.id)')
|
||||
|
|
|
@ -80,7 +80,7 @@ class ValidPartLotValidator extends ConstraintValidator
|
|||
$repo = $this->em->getRepository(Storelocation::class);
|
||||
//We can only determine associated parts, if the part have an ID
|
||||
if ($value->getID() !== null) {
|
||||
$parts = new ArrayCollection($repo->getParts($value));
|
||||
$parts = new ArrayCollection($repo->getParts($value->getStorageLocation()));
|
||||
} else {
|
||||
$parts = new ArrayCollection([]);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ class ValidPartLotValidator extends ConstraintValidator
|
|||
}
|
||||
|
||||
//Check for only single part
|
||||
if ($value->getStorageLocation()->isLimitToExistingParts()) {
|
||||
if ($value->getStorageLocation()->isOnlySinglePart()) {
|
||||
if (($parts->count() > 0) && ! $parts->contains($value->getPart())) {
|
||||
$this->context->buildViolation('validator.part_lot.single_part')
|
||||
->atPath('storage_location')->addViolation();
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -191,5 +191,11 @@
|
|||
<target>Please select a valid category!</target>
|
||||
</segment>
|
||||
</unit>
|
||||
<unit id="6vIlN5q" name="validator.part_lot.only_existing">
|
||||
<segment>
|
||||
<source>validator.part_lot.only_existing</source>
|
||||
<target>Can not add new parts to this location as it is marked as "Only Existing"</target>
|
||||
</segment>
|
||||
</unit>
|
||||
</file>
|
||||
</xliff>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue