Added some more filter possibilities.

This commit is contained in:
Jan Böhmer 2022-09-08 00:31:18 +02:00
parent 96cd746f60
commit 28c09eb51d
5 changed files with 68 additions and 4 deletions

View file

@ -21,6 +21,7 @@ use App\Entity\Parts\Supplier;
use App\Services\Trees\NodesListBuilder; use App\Services\Trees\NodesListBuilder;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\QueryBuilder; use Doctrine\ORM\QueryBuilder;
use Svg\Tag\Text;
class PartFilter implements FilterInterface class PartFilter implements FilterInterface
{ {
@ -78,6 +79,9 @@ class PartFilter implements FilterInterface
/** @var IntConstraint */ /** @var IntConstraint */
protected $orderdetailsCount; protected $orderdetailsCount;
/** @var BooleanConstraint */
protected $obsolete;
/** @var EntityConstraint */ /** @var EntityConstraint */
protected $storelocation; protected $storelocation;
@ -90,6 +94,9 @@ class PartFilter implements FilterInterface
/** @var BooleanConstraint */ /** @var BooleanConstraint */
protected $lotNeedsRefill; protected $lotNeedsRefill;
/** @var TextConstraint */
protected $lotDescription;
/** @var BooleanConstraint */ /** @var BooleanConstraint */
protected $lotUnknownAmount; protected $lotUnknownAmount;
@ -117,6 +124,9 @@ class PartFilter implements FilterInterface
/** @var ArrayCollection<int, ParameterConstraint> */ /** @var ArrayCollection<int, ParameterConstraint> */
protected $parameters; protected $parameters;
/** @var IntConstraint */
protected $parametersCount;
public function __construct(NodesListBuilder $nodesListBuilder) public function __construct(NodesListBuilder $nodesListBuilder)
{ {
$this->name = new TextConstraint('part.name'); $this->name = new TextConstraint('part.name');
@ -141,25 +151,28 @@ class PartFilter implements FilterInterface
*/ */
$this->amountSum = new IntConstraint('amountSum'); $this->amountSum = new IntConstraint('amountSum');
$this->lotCount = new IntConstraint('COUNT(partLots)'); $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->lotNeedsRefill = new BooleanConstraint('partLots.needs_refill');
$this->lotUnknownAmount = new BooleanConstraint('partLots.instock_unknown'); $this->lotUnknownAmount = new BooleanConstraint('partLots.instock_unknown');
$this->lotExpirationDate = new DateTimeConstraint('partLots.expiration_date'); $this->lotExpirationDate = new DateTimeConstraint('partLots.expiration_date');
$this->lotDescription = new TextConstraint('partLots.description');
$this->manufacturer = new EntityConstraint($nodesListBuilder, Manufacturer::class, 'part.manufacturer'); $this->manufacturer = new EntityConstraint($nodesListBuilder, Manufacturer::class, 'part.manufacturer');
$this->manufacturer_product_number = new TextConstraint('part.manufacturer_product_number'); $this->manufacturer_product_number = new TextConstraint('part.manufacturer_product_number');
$this->manufacturer_product_url = new TextConstraint('part.manufacturer_product_url'); $this->manufacturer_product_url = new TextConstraint('part.manufacturer_product_url');
$this->manufacturing_status = new ChoiceConstraint('part.manufacturing_status'); $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->attachmentsCount = new IntConstraint('COUNT(attachments)');
$this->attachmentType = new EntityConstraint($nodesListBuilder, AttachmentType::class, 'attachments.attachment_type'); $this->attachmentType = new EntityConstraint($nodesListBuilder, AttachmentType::class, 'attachments.attachment_type');
$this->attachmentName = new TextConstraint('attachments.name'); $this->attachmentName = new TextConstraint('attachments.name');
$this->supplier = new EntityConstraint($nodesListBuilder, Supplier::class, 'orderdetails.supplier');
$this->orderdetailsCount = new IntConstraint('COUNT(orderdetails)'); $this->orderdetailsCount = new IntConstraint('COUNT(orderdetails)');
$this->obsolete = new BooleanConstraint('orderdetails.obsolete');
$this->parameters = new ArrayCollection(); $this->parameters = new ArrayCollection();
$this->parametersCount = new IntConstraint('COUNT(parameters)');
} }
public function apply(QueryBuilder $queryBuilder): void public function apply(QueryBuilder $queryBuilder): void
@ -387,6 +400,28 @@ class PartFilter implements FilterInterface
return $this->parameters; 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;
}
} }

View file

@ -362,6 +362,7 @@ final class PartsDataTable implements DataTableTypeInterface
->leftJoin('orderdetails.supplier', 'suppliers') ->leftJoin('orderdetails.supplier', 'suppliers')
->leftJoin('part.attachments', 'attachments') ->leftJoin('part.attachments', 'attachments')
->leftJoin('part.partUnit', 'partUnit') ->leftJoin('part.partUnit', 'partUnit')
->leftJoin('part.parameters', 'parameters')
->groupBy('part') ->groupBy('part')
; ;

View file

@ -156,6 +156,9 @@ class PartFilterType extends AbstractType
'min' => 0, 'min' => 0,
]); ]);
$builder->add('obsolete', BooleanConstraintType::class, [
'label' => 'orderdetails.edit.obsolete'
]);
/* /*
* Stocks tabs * Stocks tabs
@ -194,6 +197,10 @@ class PartFilterType extends AbstractType
'input_type' => DateType::class, 'input_type' => DateType::class,
]); ]);
$builder->add('lotDescription', TextConstraintType::class, [
'label' => 'part.filter.lotDescription',
]);
/** /**
* Attachments count * Attachments count
*/ */
@ -215,7 +222,7 @@ class PartFilterType extends AbstractType
$constraint_prototype = new ParameterConstraint(); $constraint_prototype = new ParameterConstraint();
$builder->add('parameters', CollectionType::class, [ $builder->add('parameters', CollectionType::class, [
'label' => 'parameter.label', 'label' => false,
'entry_type' => ParameterConstraintType::class, 'entry_type' => ParameterConstraintType::class,
'allow_delete' => true, 'allow_delete' => true,
'allow_add' => true, 'allow_add' => true,
@ -224,6 +231,12 @@ class PartFilterType extends AbstractType
'empty_data' => $constraint_prototype, 'empty_data' => $constraint_prototype,
]); ]);
$builder->add('parametersCount', NumberConstraintType::class, [
'label' => 'part.filter.parameters_count',
'step' => 1,
'min' => 0,
]);
$builder->add('submit', SubmitType::class, [ $builder->add('submit', SubmitType::class, [
'label' => 'filter.submit', 'label' => 'filter.submit',
]); ]);

View file

@ -60,6 +60,7 @@
{{ form_row(filterForm.amountSum) }} {{ form_row(filterForm.amountSum) }}
{{ form_row(filterForm.lotCount) }} {{ form_row(filterForm.lotCount) }}
{{ form_row(filterForm.lotExpirationDate) }} {{ form_row(filterForm.lotExpirationDate) }}
{{ form_row(filterForm.lotDescription) }}
{{ form_row(filterForm.lotNeedsRefill) }} {{ form_row(filterForm.lotNeedsRefill) }}
{{ form_row(filterForm.lotUnknownAmount) }} {{ form_row(filterForm.lotUnknownAmount) }}
</div> </div>
@ -73,10 +74,12 @@
<div class="tab-pane pt-3" id="filter-orderdetails" role="tabpanel" aria-labelledby="filter-orderdetails-tab" tabindex="0"> <div class="tab-pane pt-3" id="filter-orderdetails" role="tabpanel" aria-labelledby="filter-orderdetails-tab" tabindex="0">
{{ form_row(filterForm.supplier) }} {{ form_row(filterForm.supplier) }}
{{ form_row(filterForm.orderdetailsCount) }} {{ form_row(filterForm.orderdetailsCount) }}
{{ form_row(filterForm.obsolete) }}
</div> </div>
<div class="tab-pane pt-3" id="filter-parameters" role="tabpanel" aria-labelledby="filter-parameters-tab" tabindex="0"> <div class="tab-pane pt-3" id="filter-parameters" role="tabpanel" aria-labelledby="filter-parameters-tab" tabindex="0">
{% import 'components/collection_type.macro.html.twig' as collection %} {% import 'components/collection_type.macro.html.twig' as collection %}
{{ form_row(filterForm.parametersCount) }}
<div {{ collection.controller(filterForm.parameters) }}> <div {{ collection.controller(filterForm.parameters) }}>
<table class="table table-striped table-sm" id="lots_table" {{ collection.target() }}> <table class="table table-striped table-sm" id="lots_table" {{ collection.target() }}>

View file

@ -9669,5 +9669,17 @@ Element 3</target>
<target>Add constraint</target> <target>Add constraint</target>
</segment> </segment>
</unit> </unit>
<unit id=".CuxL5L" name="part.filter.parameters_count">
<segment>
<source>part.filter.parameters_count</source>
<target>Number of parameters</target>
</segment>
</unit>
<unit id="Dn0SKIi" name="part.filter.lotDescription">
<segment>
<source>part.filter.lotDescription</source>
<target>Lot description</target>
</segment>
</unit>
</file> </file>
</xliff> </xliff>