mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Allow part lots to have an null storage location.
Otherwise we loose informations on migration.
This commit is contained in:
parent
c7e8fc9642
commit
016c2889ba
4 changed files with 16 additions and 8 deletions
|
@ -71,9 +71,9 @@ class PartLot extends DBElement
|
||||||
protected $expiration_date;
|
protected $expiration_date;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Storelocation The storelocation of this lot
|
* @var Storelocation|null The storelocation of this lot
|
||||||
* @ORM\ManyToOne(targetEntity="Storelocation")
|
* @ORM\ManyToOne(targetEntity="Storelocation")
|
||||||
* @ORM\JoinColumn(name="id_store_location", referencedColumnName="id")
|
* @ORM\JoinColumn(name="id_store_location", referencedColumnName="id", nullable=true)
|
||||||
* @Selectable()
|
* @Selectable()
|
||||||
*/
|
*/
|
||||||
protected $storage_location;
|
protected $storage_location;
|
||||||
|
@ -82,6 +82,7 @@ class PartLot extends DBElement
|
||||||
* @var Part The part that is stored in this lot
|
* @var Part The part that is stored in this lot
|
||||||
* @ORM\ManyToOne(targetEntity="Part", inversedBy="partLots")
|
* @ORM\ManyToOne(targetEntity="Part", inversedBy="partLots")
|
||||||
* @ORM\JoinColumn(name="id_part", referencedColumnName="id")
|
* @ORM\JoinColumn(name="id_part", referencedColumnName="id")
|
||||||
|
* @Assert\NotNull()
|
||||||
*/
|
*/
|
||||||
protected $part;
|
protected $part;
|
||||||
|
|
||||||
|
@ -195,7 +196,7 @@ class PartLot extends DBElement
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the storage locatiion, where this part lot is stored.
|
* Gets the storage locatiion, where this part lot is stored.
|
||||||
* @return Storelocation The store location where this part is stored
|
* @return Storelocation|null The store location where this part is stored
|
||||||
*/
|
*/
|
||||||
public function getStorageLocation(): ?Storelocation
|
public function getStorageLocation(): ?Storelocation
|
||||||
{
|
{
|
||||||
|
@ -204,10 +205,10 @@ class PartLot extends DBElement
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the storage location, where this part lot is stored
|
* Sets the storage location, where this part lot is stored
|
||||||
* @param Storelocation $storage_location
|
* @param Storelocation|null $storage_location
|
||||||
* @return PartLot
|
* @return PartLot
|
||||||
*/
|
*/
|
||||||
public function setStorageLocation(Storelocation $storage_location): PartLot
|
public function setStorageLocation(?Storelocation $storage_location): PartLot
|
||||||
{
|
{
|
||||||
$this->storage_location = $storage_location;
|
$this->storage_location = $storage_location;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -58,6 +58,7 @@ class PartLotType extends AbstractType
|
||||||
|
|
||||||
$builder->add('storage_location', StructuralEntityType::class, ['class' => Storelocation::class,
|
$builder->add('storage_location', StructuralEntityType::class, ['class' => Storelocation::class,
|
||||||
'label' => 'part_lot.edit.location',
|
'label' => 'part_lot.edit.location',
|
||||||
|
'required' => false,
|
||||||
'disable_not_selectable' => true,
|
'disable_not_selectable' => true,
|
||||||
'attr' => ['class' => 'selectpicker form-control-sm', 'data-live-search' => true]]);
|
'attr' => ['class' => 'selectpicker form-control-sm', 'data-live-search' => true]]);
|
||||||
|
|
||||||
|
|
|
@ -32,14 +32,14 @@ final class Version20190812154222 extends AbstractMigration
|
||||||
$this->addSql(
|
$this->addSql(
|
||||||
'INSERT INTO part_lots (id_part, id_store_location, amount, instock_unknown, last_modified, datetime_added) ' .
|
'INSERT INTO part_lots (id_part, id_store_location, amount, instock_unknown, last_modified, datetime_added) ' .
|
||||||
'SELECT parts.id, parts.id_storelocation, parts.instock, 0, NOW(), NOW() FROM parts ' .
|
'SELECT parts.id, parts.id_storelocation, parts.instock, 0, NOW(), NOW() FROM parts ' .
|
||||||
'WHERE parts.instock >= 0 AND parts.id_storelocation IS NOT NULL'
|
'WHERE parts.instock >= 0'
|
||||||
);
|
);
|
||||||
|
|
||||||
//Migrate part locations for parts with unknown instock
|
//Migrate part locations for parts with unknown instock
|
||||||
$this->addSql(
|
$this->addSql(
|
||||||
'INSERT INTO part_lots (id_part, id_store_location, amount, instock_unknown, last_modified, datetime_added) ' .
|
'INSERT INTO part_lots (id_part, id_store_location, amount, instock_unknown, last_modified, datetime_added) ' .
|
||||||
'SELECT parts.id, parts.id_storelocation, 0, 1, NOW(), NOW() FROM parts ' .
|
'SELECT parts.id, parts.id_storelocation, 0, 1, NOW(), NOW() FROM parts ' .
|
||||||
'WHERE parts.instock = -2 AND parts.id_storelocation IS NOT NULL'
|
'WHERE parts.instock = -2'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->addSql('ALTER TABLE attachements CHANGE element_id element_id INT DEFAULT NULL, CHANGE type_id type_id INT DEFAULT NULL, CHANGE last_modified last_modified DATETIME NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL');
|
$this->addSql('ALTER TABLE attachements CHANGE element_id element_id INT DEFAULT NULL, CHANGE type_id type_id INT DEFAULT NULL, CHANGE last_modified last_modified DATETIME NOT NULL, CHANGE datetime_added datetime_added DATETIME NOT NULL');
|
||||||
|
|
|
@ -14,7 +14,13 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ lot.description }}</td>
|
<td>{{ lot.description }}</td>
|
||||||
<td>
|
<td>
|
||||||
|
{% if lot.storageLocation %}
|
||||||
{{ lot.storageLocation.fullPath }}
|
{{ lot.storageLocation.fullPath }}
|
||||||
|
{% else %}
|
||||||
|
<span class="badge badge-pill badge-warning">
|
||||||
|
<i class="fas fa-question-circle fa-fw"></i> {% trans %}part_lots.location_unknown{% endtrans %}
|
||||||
|
</span>
|
||||||
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{% if lot.instockUnknown %}
|
{% if lot.instockUnknown %}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue