mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 18:58:46 +02:00
Show parts count on AdminPages of PartsContainingDBElements
This commit is contained in:
parent
082608dbd9
commit
e19cd67b88
10 changed files with 97 additions and 38 deletions
|
@ -60,7 +60,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||
*
|
||||
* @ORM\MappedSuperclass()
|
||||
*/
|
||||
abstract class Company extends StructuralDBElement
|
||||
abstract class Company extends PartsContainingDBElement
|
||||
{
|
||||
/**
|
||||
* @var string The address of the company
|
||||
|
|
|
@ -52,6 +52,9 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Entity\Base;
|
||||
|
||||
use App\Entity\Parts\Part;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
/**
|
||||
|
@ -61,5 +64,23 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
*/
|
||||
abstract class PartsContainingDBElement extends StructuralDBElement
|
||||
{
|
||||
/**
|
||||
* @var Part[]|Collection
|
||||
*/
|
||||
protected $parts;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->parts = new ArrayCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the parts associated with this element.
|
||||
* @return Collection|Part[]
|
||||
*/
|
||||
public function getParts() : Collection
|
||||
{
|
||||
return $this->parts;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ class Category extends PartsContainingDBElement
|
|||
protected $parent;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Part", mappedBy="category")
|
||||
* @ORM\OneToMany(targetEntity="Part", mappedBy="category", fetch="EXTRA_LAZY")
|
||||
*/
|
||||
protected $parts;
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ class Footprint extends PartsContainingDBElement
|
|||
protected $filename;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Part", mappedBy="footprint")
|
||||
* @ORM\OneToMany(targetEntity="Part", mappedBy="footprint", fetch="EXTRA_LAZY")
|
||||
*/
|
||||
protected $parts;
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ class Manufacturer extends Company
|
|||
protected $parent;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Part", mappedBy="manufacturer")
|
||||
* @ORM\OneToMany(targetEntity="Part", mappedBy="manufacturer", fetch="EXTRA_LAZY")
|
||||
*/
|
||||
protected $parts;
|
||||
|
||||
|
|
|
@ -82,6 +82,11 @@ class MeasurementUnit extends PartsContainingDBElement
|
|||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Part", mappedBy="partUnit", fetch="EXTRA_LAZY")
|
||||
*/
|
||||
protected $parts;
|
||||
|
||||
/**
|
||||
* Returns the ID as an string, defined by the element class.
|
||||
* This should have a form like P000014, for a part with ID 14.
|
||||
|
|
|
@ -61,6 +61,7 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Entity\Parts;
|
||||
|
||||
use App\Entity\Base\PartsContainingDBElement;
|
||||
use App\Entity\Base\StructuralDBElement;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
|
@ -70,7 +71,7 @@ use Doctrine\ORM\Mapping as ORM;
|
|||
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
|
||||
* @ORM\Table("`storelocations`")
|
||||
*/
|
||||
class Storelocation extends StructuralDBElement
|
||||
class Storelocation extends PartsContainingDBElement
|
||||
{
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Storelocation", mappedBy="parent")
|
||||
|
@ -108,6 +109,15 @@ class Storelocation extends StructuralDBElement
|
|||
*/
|
||||
protected $storage_type;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Part", fetch="EXTRA_LAZY")
|
||||
* @ORM\JoinTable(name="part_lots",
|
||||
* joinColumns={@ORM\JoinColumn(name="id_store_location", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="id_part", referencedColumnName="id")}
|
||||
* )
|
||||
*/
|
||||
protected $parts;
|
||||
|
||||
/********************************************************************************
|
||||
*
|
||||
* Getters
|
||||
|
|
|
@ -107,6 +107,15 @@ class Supplier extends Company
|
|||
*/
|
||||
protected $shipping_costs;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToMany(targetEntity="Part", fetch="EXTRA_LAZY")
|
||||
* @ORM\JoinTable(name="orderdetails",
|
||||
* joinColumns={@ORM\JoinColumn(name="id_supplier", referencedColumnName="id")},
|
||||
* inverseJoinColumns={@ORM\JoinColumn(name="part_id", referencedColumnName="id")}
|
||||
* )
|
||||
*/
|
||||
protected $parts;
|
||||
|
||||
/**
|
||||
* @return ?Currency
|
||||
*/
|
||||
|
|
|
@ -96,39 +96,7 @@
|
|||
</div>
|
||||
|
||||
<div id="info" class="tab-pane fade">
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-3">{% trans %}id.label{% endtrans %}</label>
|
||||
<div class="col-md-9">
|
||||
<p class="form-control-plaintext">{% if entity.iD %}{{ entity.id }}{% else %}-{% endif %}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-3">{% trans %}createdAt{% endtrans %}</label>
|
||||
<div class="col-md-9">
|
||||
<p class="form-control-plaintext">
|
||||
|
||||
{% if date(entity.addedDate) > date('1900/01/01') %}
|
||||
{{ entity.addedDate | localizeddate("long") }}
|
||||
{% else %}
|
||||
-
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-3">{% trans %}lastModified{% endtrans %}</label>
|
||||
<div class="col-md-9">
|
||||
<p class="form-control-plaintext">
|
||||
{% if date(entity.lastModified) > date('1900/01/01') %}
|
||||
{{ entity.lastModified | localizeddate("long") }}
|
||||
{% else %}
|
||||
-
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{% include "AdminPages/_info.html.twig" %}
|
||||
</div>
|
||||
|
||||
|
||||
|
|
46
templates/AdminPages/_info.html.twig
Normal file
46
templates/AdminPages/_info.html.twig
Normal file
|
@ -0,0 +1,46 @@
|
|||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-3">{% trans %}id.label{% endtrans %}</label>
|
||||
<div class="col-md-9">
|
||||
<p class="form-control-plaintext">{% if entity.iD %}{{ entity.id }}{% else %}-{% endif %}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-3">{% trans %}createdAt{% endtrans %}</label>
|
||||
<div class="col-md-9">
|
||||
<p class="form-control-plaintext">
|
||||
|
||||
{% if date(entity.addedDate) > date('1900/01/01') %}
|
||||
{{ entity.addedDate | localizeddate("long") }}
|
||||
{% else %}
|
||||
-
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-3">{% trans %}lastModified{% endtrans %}</label>
|
||||
<div class="col-md-9">
|
||||
<p class="form-control-plaintext">
|
||||
{% if date(entity.lastModified) > date('1900/01/01') %}
|
||||
{{ entity.lastModified | localizeddate("long") }}
|
||||
{% else %}
|
||||
-
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group row">
|
||||
<label class="col-form-label col-md-3">{% trans %}entity.info.parts_count{% endtrans %}</label>
|
||||
<div class="col-md-9">
|
||||
<p class="form-control-static">
|
||||
{% if entity.id and entity.parts is defined %}
|
||||
{{ entity.parts | length }}
|
||||
{% else %}
|
||||
-
|
||||
{% endif %}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
Loading…
Add table
Add a link
Reference in a new issue