Show parts count on AdminPages of PartsContainingDBElements

This commit is contained in:
Jan Böhmer 2019-09-04 19:37:35 +02:00
parent 082608dbd9
commit e19cd67b88
10 changed files with 97 additions and 38 deletions

View file

@ -60,7 +60,7 @@ use Symfony\Component\Validator\Constraints as Assert;
* *
* @ORM\MappedSuperclass() * @ORM\MappedSuperclass()
*/ */
abstract class Company extends StructuralDBElement abstract class Company extends PartsContainingDBElement
{ {
/** /**
* @var string The address of the company * @var string The address of the company

View file

@ -52,6 +52,9 @@ declare(strict_types=1);
namespace App\Entity\Base; 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; use Doctrine\ORM\Mapping as ORM;
/** /**
@ -61,5 +64,23 @@ use Doctrine\ORM\Mapping as ORM;
*/ */
abstract class PartsContainingDBElement extends StructuralDBElement abstract class PartsContainingDBElement extends StructuralDBElement
{ {
/**
* @var Part[]|Collection
*/
protected $parts; 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;
}
} }

View file

@ -75,7 +75,7 @@ class Category extends PartsContainingDBElement
protected $parent; protected $parent;
/** /**
* @ORM\OneToMany(targetEntity="Part", mappedBy="category") * @ORM\OneToMany(targetEntity="Part", mappedBy="category", fetch="EXTRA_LAZY")
*/ */
protected $parts; protected $parts;

View file

@ -90,7 +90,7 @@ class Footprint extends PartsContainingDBElement
protected $filename; protected $filename;
/** /**
* @ORM\OneToMany(targetEntity="Part", mappedBy="footprint") * @ORM\OneToMany(targetEntity="Part", mappedBy="footprint", fetch="EXTRA_LAZY")
*/ */
protected $parts; protected $parts;

View file

@ -84,7 +84,7 @@ class Manufacturer extends Company
protected $parent; protected $parent;
/** /**
* @ORM\OneToMany(targetEntity="Part", mappedBy="manufacturer") * @ORM\OneToMany(targetEntity="Part", mappedBy="manufacturer", fetch="EXTRA_LAZY")
*/ */
protected $parts; protected $parts;

View file

@ -82,6 +82,11 @@ class MeasurementUnit extends PartsContainingDBElement
*/ */
protected $parent; protected $parent;
/**
* @ORM\OneToMany(targetEntity="Part", mappedBy="partUnit", fetch="EXTRA_LAZY")
*/
protected $parts;
/** /**
* Returns the ID as an string, defined by the element class. * Returns the ID as an string, defined by the element class.
* This should have a form like P000014, for a part with ID 14. * This should have a form like P000014, for a part with ID 14.

View file

@ -61,6 +61,7 @@ declare(strict_types=1);
namespace App\Entity\Parts; namespace App\Entity\Parts;
use App\Entity\Base\PartsContainingDBElement;
use App\Entity\Base\StructuralDBElement; use App\Entity\Base\StructuralDBElement;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
@ -70,7 +71,7 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository") * @ORM\Entity(repositoryClass="App\Repository\StructuralDBElementRepository")
* @ORM\Table("`storelocations`") * @ORM\Table("`storelocations`")
*/ */
class Storelocation extends StructuralDBElement class Storelocation extends PartsContainingDBElement
{ {
/** /**
* @ORM\OneToMany(targetEntity="Storelocation", mappedBy="parent") * @ORM\OneToMany(targetEntity="Storelocation", mappedBy="parent")
@ -108,6 +109,15 @@ class Storelocation extends StructuralDBElement
*/ */
protected $storage_type; 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 * Getters

View file

@ -107,6 +107,15 @@ class Supplier extends Company
*/ */
protected $shipping_costs; 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 * @return ?Currency
*/ */

View file

@ -96,39 +96,7 @@
</div> </div>
<div id="info" class="tab-pane fade"> <div id="info" class="tab-pane fade">
<div class="form-group row"> {% include "AdminPages/_info.html.twig" %}
<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> </div>

View 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>