mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Allow to show parts in a storelocation or an supplier.
This commit is contained in:
parent
748905c325
commit
31e89e2e36
8 changed files with 107 additions and 6 deletions
|
@ -33,6 +33,8 @@ use App\DataTables\PartsDataTable;
|
||||||
use App\Entity\Parts\Category;
|
use App\Entity\Parts\Category;
|
||||||
use App\Entity\Parts\Footprint;
|
use App\Entity\Parts\Footprint;
|
||||||
use App\Entity\Parts\Manufacturer;
|
use App\Entity\Parts\Manufacturer;
|
||||||
|
use App\Entity\Parts\Storelocation;
|
||||||
|
use App\Entity\Parts\Supplier;
|
||||||
use Omines\DataTablesBundle\DataTableFactory;
|
use Omines\DataTablesBundle\DataTableFactory;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
@ -106,6 +108,51 @@ class PartListsController extends AbstractController
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/store_location/{id}/parts", name="part_list_store_location")
|
||||||
|
*
|
||||||
|
* @param $id int The id of the category
|
||||||
|
*
|
||||||
|
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
|
*/
|
||||||
|
public function showStorelocation(Storelocation $storelocation, Request $request, DataTableFactory $dataTable)
|
||||||
|
{
|
||||||
|
$table = $dataTable->createFromType(PartsDataTable::class, ['storelocation' => $storelocation])
|
||||||
|
->handleRequest($request);
|
||||||
|
|
||||||
|
if ($table->isCallback()) {
|
||||||
|
return $table->getResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('Parts/lists/store_location_list.html.twig', [
|
||||||
|
'datatable' => $table,
|
||||||
|
'entity' => $storelocation
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Route("/supplier/{id}/parts", name="part_list_supplier")
|
||||||
|
*
|
||||||
|
* @param $id int The id of the category
|
||||||
|
*
|
||||||
|
* @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
|
*/
|
||||||
|
public function showSupplier(Supplier $supplier, Request $request, DataTableFactory $dataTable)
|
||||||
|
{
|
||||||
|
$table = $dataTable->createFromType(PartsDataTable::class, ['supplier' => $supplier])
|
||||||
|
->handleRequest($request);
|
||||||
|
|
||||||
|
if ($table->isCallback()) {
|
||||||
|
return $table->getResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->render('Parts/lists/supplier_list.html.twig', [
|
||||||
|
'datatable' => $table,
|
||||||
|
'entity' => $supplier
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route("/parts/by_tag/{tag}", name="part_list_tags")
|
* @Route("/parts/by_tag/{tag}", name="part_list_tags")
|
||||||
* @param string $tag
|
* @param string $tag
|
||||||
|
|
|
@ -99,7 +99,7 @@ class TreeController extends AbstractController
|
||||||
if ($location !== null) {
|
if ($location !== null) {
|
||||||
$tree[] = $builder->elementToTreeNode($location);
|
$tree[] = $builder->elementToTreeNode($location);
|
||||||
} else {
|
} else {
|
||||||
$tree = $builder->typeToTree(Storelocation::class, null);
|
$tree = $builder->typeToTree(Storelocation::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ class TreeController extends AbstractController
|
||||||
if ($supplier !== null) {
|
if ($supplier !== null) {
|
||||||
$tree[] = $builder->elementToTreeNode($supplier);
|
$tree[] = $builder->elementToTreeNode($supplier);
|
||||||
} else {
|
} else {
|
||||||
$tree = $builder->typeToTree(Supplier::class, null);
|
$tree = $builder->typeToTree(Supplier::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,6 +35,8 @@ use App\Entity\Parts\Category;
|
||||||
use App\Entity\Parts\Footprint;
|
use App\Entity\Parts\Footprint;
|
||||||
use App\Entity\Parts\Manufacturer;
|
use App\Entity\Parts\Manufacturer;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
|
use App\Entity\Parts\Storelocation;
|
||||||
|
use App\Entity\Parts\Supplier;
|
||||||
use App\Services\EntityURLGenerator;
|
use App\Services\EntityURLGenerator;
|
||||||
use Doctrine\ORM\QueryBuilder;
|
use Doctrine\ORM\QueryBuilder;
|
||||||
use Omines\DataTablesBundle\Adapter\Doctrine\ORM\SearchCriteriaProvider;
|
use Omines\DataTablesBundle\Adapter\Doctrine\ORM\SearchCriteriaProvider;
|
||||||
|
@ -63,15 +65,17 @@ class PartsDataTable implements DataTableTypeInterface
|
||||||
|
|
||||||
protected function getQuery(QueryBuilder $builder)
|
protected function getQuery(QueryBuilder $builder)
|
||||||
{
|
{
|
||||||
$builder->select('part')
|
$builder->distinct()->select('part')
|
||||||
->addSelect('category')
|
->addSelect('category')
|
||||||
->addSelect('footprint')
|
->addSelect('footprint')
|
||||||
->addSelect('manufacturer')
|
->addSelect('manufacturer')
|
||||||
->addSelect('partUnit')
|
->addSelect('partUnit')
|
||||||
->from(Part::class, 'part')
|
->from(Part::class, 'part')
|
||||||
->leftJoin('part.category', 'category')
|
->leftJoin('part.category', 'category')
|
||||||
|
->leftJoin('part.partLots', 'partLots')
|
||||||
->leftJoin('part.footprint', 'footprint')
|
->leftJoin('part.footprint', 'footprint')
|
||||||
->leftJoin('part.manufacturer', 'manufacturer')
|
->leftJoin('part.manufacturer', 'manufacturer')
|
||||||
|
->leftJoin('part.orderdetails', 'orderdetails')
|
||||||
->leftJoin('part.partUnit', 'partUnit');
|
->leftJoin('part.partUnit', 'partUnit');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,6 +110,24 @@ class PartsDataTable implements DataTableTypeInterface
|
||||||
$builder->andWhere('part.manufacturer IN (:cid)')->setParameter('cid', $list);
|
$builder->andWhere('part.manufacturer IN (:cid)')->setParameter('cid', $list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($options['storelocation'])) {
|
||||||
|
$location = $options['storelocation'];
|
||||||
|
$repo = $em->getRepository(Storelocation::class);
|
||||||
|
$list = $repo->toNodesList($location);
|
||||||
|
$list[] = $location;
|
||||||
|
|
||||||
|
$builder->andWhere('partLots.storage_location IN (:cid)')->setParameter('cid', $list);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($options['supplier'])) {
|
||||||
|
$location = $options['supplier'];
|
||||||
|
$repo = $em->getRepository(Supplier::class);
|
||||||
|
$list = $repo->toNodesList($location);
|
||||||
|
$list[] = $location;
|
||||||
|
|
||||||
|
$builder->andWhere('orderdetails.supplier IN (:cid)')->setParameter('cid', $list);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($options['tag'])) {
|
if (isset($options['tag'])) {
|
||||||
$builder->andWhere('part.tags LIKE :tag')->setParameter('tag', '%' . $options['tag'] . '%');
|
$builder->andWhere('part.tags LIKE :tag')->setParameter('tag', '%' . $options['tag'] . '%');
|
||||||
}
|
}
|
||||||
|
|
|
@ -257,7 +257,9 @@ class EntityURLGenerator
|
||||||
$map = [
|
$map = [
|
||||||
Category::class => 'part_list_category',
|
Category::class => 'part_list_category',
|
||||||
Footprint::class => 'part_list_footprint',
|
Footprint::class => 'part_list_footprint',
|
||||||
Manufacturer::class => 'part_list_manufacturer'
|
Manufacturer::class => 'part_list_manufacturer',
|
||||||
|
Supplier::class => 'part_list_supplier',
|
||||||
|
Storelocation::class => 'part_list_store_location'
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->urlGenerator->generate($this->mapToController($map, $entity), ['id' => $entity->getID()]);
|
return $this->urlGenerator->generate($this->mapToController($map, $entity), ['id' => $entity->getID()]);
|
||||||
|
|
|
@ -11,7 +11,9 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for order in part.orderdetails %}
|
{% for order in part.orderdetails %}
|
||||||
<tr class="{% if order.obsolete %}table-danger{% endif %}">
|
<tr class="{% if order.obsolete %}table-danger{% endif %}">
|
||||||
<td>{{ order.supplier.name }}</td>
|
<td>
|
||||||
|
<a href="{{ order.supplier | entityURL('list_parts') }}">{{ order.supplier.name }}</a>
|
||||||
|
</td>
|
||||||
<td>{% if order.supplierProductUrl is not empty %}
|
<td>{% if order.supplierProductUrl is not empty %}
|
||||||
<a href="{{ order.supplierProductUrl }}" target="_blank" class="link-external">{{ order.supplierPartNr }}</a>
|
<a href="{{ order.supplierProductUrl }}" target="_blank" class="link-external">{{ order.supplierPartNr }}</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
{% import "helper.twig" as helper %}
|
||||||
|
|
||||||
<table class="table table-striped table-hover">
|
<table class="table table-striped table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -15,7 +17,7 @@
|
||||||
<td>{{ lot.description }}</td>
|
<td>{{ lot.description }}</td>
|
||||||
<td>
|
<td>
|
||||||
{% if lot.storageLocation %}
|
{% if lot.storageLocation %}
|
||||||
{{ lot.storageLocation.fullPath }}
|
{{ helper.structural_entity_link(lot.storageLocation) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<span class="badge badge-pill badge-warning">
|
<span class="badge badge-pill badge-warning">
|
||||||
<i class="fas fa-question-circle fa-fw"></i> {% trans %}part_lots.location_unknown{% endtrans %}
|
<i class="fas fa-question-circle fa-fw"></i> {% trans %}part_lots.location_unknown{% endtrans %}
|
||||||
|
|
13
templates/Parts/lists/store_location_list.html.twig
Normal file
13
templates/Parts/lists/store_location_list.html.twig
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{% extends "base.html.twig" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{% trans %}parts_list.storelocation.title{% endtrans %} {{ entity.name }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% include "Parts/lists/_info_card.html.twig" with {'header_label': 'storelocation.label'} %}
|
||||||
|
|
||||||
|
{% include "Parts/lists/_parts_list.html.twig" %}
|
||||||
|
|
||||||
|
{% endblock %}
|
13
templates/Parts/lists/supplier_list.html.twig
Normal file
13
templates/Parts/lists/supplier_list.html.twig
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{% extends "base.html.twig" %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{% trans %}parts_list.supplier.title{% endtrans %} {{ entity.name }}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% include "Parts/lists/_info_card.html.twig" with {'header_label': 'supplier.label'} %}
|
||||||
|
|
||||||
|
{% include "Parts/lists/_parts_list.html.twig" %}
|
||||||
|
|
||||||
|
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue