diff --git a/src/DataTables/Filters/PartFilter.php b/src/DataTables/Filters/PartFilter.php index f6e9c277..77b11ab8 100644 --- a/src/DataTables/Filters/PartFilter.php +++ b/src/DataTables/Filters/PartFilter.php @@ -77,6 +77,15 @@ class PartFilter implements FilterInterface /** @var IntConstraint */ protected $lotCount; + /** @var BooleanConstraint */ + protected $lotNeedsRefill; + + /** @var BooleanConstraint */ + protected $lotUnknownAmount; + + /** @var DateTimeConstraint */ + protected $lotExpirationDate; + /** @var EntityConstraint */ protected $measurementUnit; @@ -107,7 +116,11 @@ class PartFilter implements FilterInterface $this->lastModified = new DateTimeConstraint('part.lastModified'); $this->minAmount = new NumberConstraint('part.minAmount'); + $this->lotCount = new IntConstraint('COUNT(partLots)'); $this->supplier = new EntityConstraint($nodesListBuilder, Supplier::class, 'orderdetails.supplier'); + $this->lotNeedsRefill = new BooleanConstraint('partLots.needs_refill'); + $this->lotUnknownAmount = new BooleanConstraint('partLots.instock_unknown'); + $this->lotExpirationDate = new DateTimeConstraint('partLots.expiration_date'); $this->manufacturer = new EntityConstraint($nodesListBuilder, Manufacturer::class, 'part.manufacturer'); $this->manufacturer_product_number = new TextConstraint('part.manufacturer_product_number'); @@ -115,7 +128,6 @@ class PartFilter implements FilterInterface $this->storelocation = new EntityConstraint($nodesListBuilder, Storelocation::class, 'partLots.storage_location'); - $this->lotCount = new IntConstraint('COUNT(partLots)'); $this->attachmentsCount = new IntConstraint('COUNT(attachments)'); $this->orderdetailsCount = new IntConstraint('COUNT(orderdetails)'); } @@ -287,5 +299,30 @@ class PartFilter implements FilterInterface return $this->attachmentsCount; } + /** + * @return BooleanConstraint + */ + public function getLotNeedsRefill(): BooleanConstraint + { + return $this->lotNeedsRefill; + } + + /** + * @return BooleanConstraint + */ + public function getLotUnknownAmount(): BooleanConstraint + { + return $this->lotUnknownAmount; + } + + /** + * @return DateTimeConstraint + */ + public function getLotExpirationDate(): DateTimeConstraint + { + return $this->lotExpirationDate; + } + + } diff --git a/src/Form/Filters/Constraints/DateTimeConstraintType.php b/src/Form/Filters/Constraints/DateTimeConstraintType.php index 6ac4e177..96a3b940 100644 --- a/src/Form/Filters/Constraints/DateTimeConstraintType.php +++ b/src/Form/Filters/Constraints/DateTimeConstraintType.php @@ -24,6 +24,7 @@ class DateTimeConstraintType extends AbstractType 'value1_options' => [], // Options for the first value input 'value2_options' => [], // Options for the second value input + 'input_type' => DateTimeType::class, ]); } @@ -40,7 +41,7 @@ class DateTimeConstraintType extends AbstractType 'filter.number_constraint.value.operator.BETWEEN' => 'BETWEEN', ]; - $builder->add('value1', DateTimeType::class, array_merge_recursive([ + $builder->add('value1', $options['input_type'], array_merge_recursive([ 'label' => 'filter.datetime_constraint.value1', 'attr' => [ 'placeholder' => 'filter.datetime_constraint.value1', @@ -50,7 +51,7 @@ class DateTimeConstraintType extends AbstractType 'widget' => 'single_text', ], $options['value1_options'])); - $builder->add('value2', DateTimeType::class, array_merge_recursive([ + $builder->add('value2', $options['input_type'], array_merge_recursive([ 'label' => 'filter.datetime_constraint.value2', 'attr' => [ 'placeholder' => 'filter.datetime_constraint.value2', diff --git a/src/Form/Filters/PartFilterType.php b/src/Form/Filters/PartFilterType.php index bf0e2cde..cf0f6bca 100644 --- a/src/Form/Filters/PartFilterType.php +++ b/src/Form/Filters/PartFilterType.php @@ -17,6 +17,7 @@ use App\Form\Filters\Constraints\TextConstraintType; use Svg\Tag\Text; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\Extension\Core\Type\DateTimeType; +use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\Extension\Core\Type\ResetType; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Symfony\Component\Form\FormBuilderInterface; @@ -156,6 +157,19 @@ class PartFilterType extends AbstractType 'step' => 1, ]); + $builder->add('lotNeedsRefill', BooleanConstraintType::class, [ + 'label' => 'part.filter.lotNeedsRefill' + ]); + + $builder->add('lotUnknownAmount', BooleanConstraintType::class, [ + 'label' => 'part.filter.lotUnknwonAmount' + ]); + + $builder->add('lotExpirationDate', DateTimeConstraintType::class, [ + 'label' => 'part.filter.lotExpirationDate', + 'input_type' => DateType::class, + ]); + /** * Attachments count */ diff --git a/templates/Parts/lists/_filter.html.twig b/templates/Parts/lists/_filter.html.twig index c236d5f2..f68f2223 100644 --- a/templates/Parts/lists/_filter.html.twig +++ b/templates/Parts/lists/_filter.html.twig @@ -54,6 +54,9 @@ {{ form_row(filterForm.storelocation) }} {{ form_row(filterForm.minAmount) }} {{ form_row(filterForm.lotCount) }} + {{ form_row(filterForm.lotExpirationDate) }} + {{ form_row(filterForm.lotNeedsRefill) }} + {{ form_row(filterForm.lotUnknownAmount) }}
diff --git a/translations/messages.en.xlf b/translations/messages.en.xlf index 06471c86..a7d63ee0 100644 --- a/translations/messages.en.xlf +++ b/translations/messages.en.xlf @@ -9477,5 +9477,23 @@ Element 3 Number of orderdetails + + + part.filter.lotExpirationDate + Lot expiration date + + + + + part.filter.lotNeedsRefill + Any lot needs refill + + + + + part.filter.lotUnknwonAmount + Any lot has unknown amount + +