diff --git a/src/DataTables/Filters/PartFilter.php b/src/DataTables/Filters/PartFilter.php index 1e6a33a3..2d3e6087 100644 --- a/src/DataTables/Filters/PartFilter.php +++ b/src/DataTables/Filters/PartFilter.php @@ -21,6 +21,7 @@ use App\Entity\Parts\Supplier; use App\Services\Trees\NodesListBuilder; use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\QueryBuilder; +use Svg\Tag\Text; class PartFilter implements FilterInterface { @@ -78,6 +79,9 @@ class PartFilter implements FilterInterface /** @var IntConstraint */ protected $orderdetailsCount; + /** @var BooleanConstraint */ + protected $obsolete; + /** @var EntityConstraint */ protected $storelocation; @@ -90,6 +94,9 @@ class PartFilter implements FilterInterface /** @var BooleanConstraint */ protected $lotNeedsRefill; + /** @var TextConstraint */ + protected $lotDescription; + /** @var BooleanConstraint */ protected $lotUnknownAmount; @@ -117,6 +124,9 @@ class PartFilter implements FilterInterface /** @var ArrayCollection */ protected $parameters; + /** @var IntConstraint */ + protected $parametersCount; + public function __construct(NodesListBuilder $nodesListBuilder) { $this->name = new TextConstraint('part.name'); @@ -141,25 +151,28 @@ class PartFilter implements FilterInterface */ $this->amountSum = new IntConstraint('amountSum'); $this->lotCount = new IntConstraint('COUNT(partLots)'); - $this->supplier = new EntityConstraint($nodesListBuilder, Supplier::class, 'orderdetails.supplier'); + + $this->storelocation = new EntityConstraint($nodesListBuilder, Storelocation::class, 'partLots.storage_location'); $this->lotNeedsRefill = new BooleanConstraint('partLots.needs_refill'); $this->lotUnknownAmount = new BooleanConstraint('partLots.instock_unknown'); $this->lotExpirationDate = new DateTimeConstraint('partLots.expiration_date'); + $this->lotDescription = new TextConstraint('partLots.description'); $this->manufacturer = new EntityConstraint($nodesListBuilder, Manufacturer::class, 'part.manufacturer'); $this->manufacturer_product_number = new TextConstraint('part.manufacturer_product_number'); $this->manufacturer_product_url = new TextConstraint('part.manufacturer_product_url'); $this->manufacturing_status = new ChoiceConstraint('part.manufacturing_status'); - $this->storelocation = new EntityConstraint($nodesListBuilder, Storelocation::class, 'partLots.storage_location'); - $this->attachmentsCount = new IntConstraint('COUNT(attachments)'); $this->attachmentType = new EntityConstraint($nodesListBuilder, AttachmentType::class, 'attachments.attachment_type'); $this->attachmentName = new TextConstraint('attachments.name'); + $this->supplier = new EntityConstraint($nodesListBuilder, Supplier::class, 'orderdetails.supplier'); $this->orderdetailsCount = new IntConstraint('COUNT(orderdetails)'); + $this->obsolete = new BooleanConstraint('orderdetails.obsolete'); $this->parameters = new ArrayCollection(); + $this->parametersCount = new IntConstraint('COUNT(parameters)'); } public function apply(QueryBuilder $queryBuilder): void @@ -387,6 +400,28 @@ class PartFilter implements FilterInterface return $this->parameters; } + public function getParametersCount(): IntConstraint + { + return $this->parametersCount; + } + + /** + * @return TextConstraint + */ + public function getLotDescription(): TextConstraint + { + return $this->lotDescription; + } + + /** + * @return BooleanConstraint + */ + public function getObsolete(): BooleanConstraint + { + return $this->obsolete; + } + + } diff --git a/src/DataTables/PartsDataTable.php b/src/DataTables/PartsDataTable.php index cc0fe1b2..53150ab3 100644 --- a/src/DataTables/PartsDataTable.php +++ b/src/DataTables/PartsDataTable.php @@ -362,6 +362,7 @@ final class PartsDataTable implements DataTableTypeInterface ->leftJoin('orderdetails.supplier', 'suppliers') ->leftJoin('part.attachments', 'attachments') ->leftJoin('part.partUnit', 'partUnit') + ->leftJoin('part.parameters', 'parameters') ->groupBy('part') ; diff --git a/src/Form/Filters/PartFilterType.php b/src/Form/Filters/PartFilterType.php index 84d3137f..99948355 100644 --- a/src/Form/Filters/PartFilterType.php +++ b/src/Form/Filters/PartFilterType.php @@ -156,6 +156,9 @@ class PartFilterType extends AbstractType 'min' => 0, ]); + $builder->add('obsolete', BooleanConstraintType::class, [ + 'label' => 'orderdetails.edit.obsolete' + ]); /* * Stocks tabs @@ -194,6 +197,10 @@ class PartFilterType extends AbstractType 'input_type' => DateType::class, ]); + $builder->add('lotDescription', TextConstraintType::class, [ + 'label' => 'part.filter.lotDescription', + ]); + /** * Attachments count */ @@ -215,7 +222,7 @@ class PartFilterType extends AbstractType $constraint_prototype = new ParameterConstraint(); $builder->add('parameters', CollectionType::class, [ - 'label' => 'parameter.label', + 'label' => false, 'entry_type' => ParameterConstraintType::class, 'allow_delete' => true, 'allow_add' => true, @@ -224,6 +231,12 @@ class PartFilterType extends AbstractType 'empty_data' => $constraint_prototype, ]); + $builder->add('parametersCount', NumberConstraintType::class, [ + 'label' => 'part.filter.parameters_count', + 'step' => 1, + 'min' => 0, + ]); + $builder->add('submit', SubmitType::class, [ 'label' => 'filter.submit', ]); diff --git a/templates/Parts/lists/_filter.html.twig b/templates/Parts/lists/_filter.html.twig index e40af175..c7f0358c 100644 --- a/templates/Parts/lists/_filter.html.twig +++ b/templates/Parts/lists/_filter.html.twig @@ -60,6 +60,7 @@ {{ form_row(filterForm.amountSum) }} {{ form_row(filterForm.lotCount) }} {{ form_row(filterForm.lotExpirationDate) }} + {{ form_row(filterForm.lotDescription) }} {{ form_row(filterForm.lotNeedsRefill) }} {{ form_row(filterForm.lotUnknownAmount) }} @@ -73,10 +74,12 @@
{{ form_row(filterForm.supplier) }} {{ form_row(filterForm.orderdetailsCount) }} + {{ form_row(filterForm.obsolete) }}
{% import 'components/collection_type.macro.html.twig' as collection %} + {{ form_row(filterForm.parametersCount) }}
diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index f80ac072..81e2113a 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -9669,5 +9669,17 @@ Element 3Add constraint + + + part.filter.parameters_count + Number of parameters + + + + + part.filter.lotDescription + Lot description + +