mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +02:00
Allow to show parts for manufacturers and footprints.
This commit is contained in:
parent
8dc9c7b9ae
commit
c3fd325645
10 changed files with 126 additions and 46 deletions
|
@ -32,6 +32,8 @@ namespace App\DataTables;
|
|||
use App\DataTables\Column\EntityColumn;
|
||||
use App\DataTables\Column\LocaleDateTimeColumn;
|
||||
use App\Entity\Parts\Category;
|
||||
use App\Entity\Parts\Footprint;
|
||||
use App\Entity\Parts\Manufacturer;
|
||||
use App\Entity\Parts\Part;
|
||||
use App\Services\EntityURLGenerator;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
|
@ -75,8 +77,9 @@ class PartsDataTable implements DataTableTypeInterface
|
|||
|
||||
protected function buildCriteria(QueryBuilder $builder, array $options)
|
||||
{
|
||||
$em = $builder->getEntityManager();
|
||||
|
||||
if (isset($options['category'])) {
|
||||
$em = $builder->getEntityManager();
|
||||
$category = $options['category'];
|
||||
$repo = $em->getRepository(Category::class);
|
||||
$list = $repo->toNodesList($category);
|
||||
|
@ -85,6 +88,24 @@ class PartsDataTable implements DataTableTypeInterface
|
|||
$builder->andWhere('part.category IN (:cid)')->setParameter('cid', $list);
|
||||
}
|
||||
|
||||
if (isset($options['footprint'])) {
|
||||
$category = $options['footprint'];
|
||||
$repo = $em->getRepository(Footprint::class);
|
||||
$list = $repo->toNodesList($category);
|
||||
$list[] = $category;
|
||||
|
||||
$builder->andWhere('part.footprint IN (:cid)')->setParameter('cid', $list);
|
||||
}
|
||||
|
||||
if (isset($options['manufacturer'])) {
|
||||
$category = $options['manufacturer'];
|
||||
$repo = $em->getRepository(Manufacturer::class);
|
||||
$list = $repo->toNodesList($category);
|
||||
$list[] = $category;
|
||||
|
||||
$builder->andWhere('part.manufacturer IN (:cid)')->setParameter('cid', $list);
|
||||
}
|
||||
|
||||
if (isset($options['tag'])) {
|
||||
$builder->andWhere('part.tags LIKE :tag')->setParameter('tag', '%' . $options['tag'] . '%');
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue