mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-29 13:10:06 +02:00
Use filter systems for most part lists.
This commit is contained in:
parent
b52c61bfa3
commit
0fc0136914
3 changed files with 106 additions and 138 deletions
|
@ -370,57 +370,12 @@ final class PartsDataTable implements DataTableTypeInterface
|
|||
|
||||
private function buildCriteria(QueryBuilder $builder, array $options): void
|
||||
{
|
||||
|
||||
//We do the most stuff here in the filter class
|
||||
if (isset($options['filter']) && $options['filter'] instanceof PartFilter) {
|
||||
$filter = $options['filter'];
|
||||
|
||||
$filter->apply($builder);
|
||||
}
|
||||
|
||||
if (isset($options['category'])) {
|
||||
$category = $options['category'];
|
||||
$list = $this->treeBuilder->typeToNodesList(Category::class, $category);
|
||||
$list[] = $category;
|
||||
|
||||
$builder->andWhere('part.category IN (:cid)')->setParameter('cid', $list);
|
||||
}
|
||||
|
||||
if (isset($options['footprint'])) {
|
||||
$category = $options['footprint'];
|
||||
$list = $this->treeBuilder->typeToNodesList(Footprint::class, $category);
|
||||
$list[] = $category;
|
||||
|
||||
$builder->andWhere('part.footprint IN (:cid)')->setParameter('cid', $list);
|
||||
}
|
||||
|
||||
if (isset($options['manufacturer'])) {
|
||||
$category = $options['manufacturer'];
|
||||
$list = $this->treeBuilder->typeToNodesList(Manufacturer::class, $category);
|
||||
$list[] = $category;
|
||||
|
||||
$builder->andWhere('part.manufacturer IN (:cid)')->setParameter('cid', $list);
|
||||
}
|
||||
|
||||
if (isset($options['storelocation'])) {
|
||||
$location = $options['storelocation'];
|
||||
$list = $this->treeBuilder->typeToNodesList(Storelocation::class, $location);
|
||||
$list[] = $location;
|
||||
|
||||
$builder->andWhere('partLots.storage_location IN (:cid)')->setParameter('cid', $list);
|
||||
}
|
||||
|
||||
if (isset($options['supplier'])) {
|
||||
$supplier = $options['supplier'];
|
||||
$list = $this->treeBuilder->typeToNodesList(Supplier::class, $supplier);
|
||||
$list[] = $supplier;
|
||||
|
||||
$builder->andWhere('orderdetails.supplier IN (:cid)')->setParameter('cid', $list);
|
||||
}
|
||||
|
||||
if (isset($options['tag'])) {
|
||||
$builder->andWhere('part.tags LIKE :tag')->setParameter('tag', $options['tag']);
|
||||
}
|
||||
|
||||
if (!empty($options['search'])) {
|
||||
if (!$options['search_options']['regex']) {
|
||||
//Dont show results, if no things are selected
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue