diff --git a/src/Entity/Parts/PartLot.php b/src/Entity/Parts/PartLot.php index 1bedc6bc..5ade5bc5 100644 --- a/src/Entity/Parts/PartLot.php +++ b/src/Entity/Parts/PartLot.php @@ -71,9 +71,9 @@ class PartLot extends DBElement protected $expiration_date; /** - * @var Storelocation The storelocation of this lot + * @var Storelocation|null The storelocation of this lot * @ORM\ManyToOne(targetEntity="Storelocation") - * @ORM\JoinColumn(name="id_store_location", referencedColumnName="id") + * @ORM\JoinColumn(name="id_store_location", referencedColumnName="id", nullable=true) * @Selectable() */ protected $storage_location; @@ -82,6 +82,7 @@ class PartLot extends DBElement * @var Part The part that is stored in this lot * @ORM\ManyToOne(targetEntity="Part", inversedBy="partLots") * @ORM\JoinColumn(name="id_part", referencedColumnName="id") + * @Assert\NotNull() */ protected $part; @@ -195,7 +196,7 @@ class PartLot extends DBElement /** * 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 { @@ -204,10 +205,10 @@ class PartLot extends DBElement /** * Sets the storage location, where this part lot is stored - * @param Storelocation $storage_location + * @param Storelocation|null $storage_location * @return PartLot */ - public function setStorageLocation(Storelocation $storage_location): PartLot + public function setStorageLocation(?Storelocation $storage_location): PartLot { $this->storage_location = $storage_location; return $this; diff --git a/src/Form/Part/PartLotType.php b/src/Form/Part/PartLotType.php index a4c1ccc0..2f4b0940 100644 --- a/src/Form/Part/PartLotType.php +++ b/src/Form/Part/PartLotType.php @@ -58,6 +58,7 @@ class PartLotType extends AbstractType $builder->add('storage_location', StructuralEntityType::class, ['class' => Storelocation::class, 'label' => 'part_lot.edit.location', + 'required' => false, 'disable_not_selectable' => true, 'attr' => ['class' => 'selectpicker form-control-sm', 'data-live-search' => true]]); diff --git a/src/Migrations/Version20190812154222.php b/src/Migrations/Version20190812154222.php index dfe2f63f..e5055dd4 100644 --- a/src/Migrations/Version20190812154222.php +++ b/src/Migrations/Version20190812154222.php @@ -32,14 +32,14 @@ final class Version20190812154222 extends AbstractMigration $this->addSql( '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 ' . - 'WHERE parts.instock >= 0 AND parts.id_storelocation IS NOT NULL' + 'WHERE parts.instock >= 0' ); //Migrate part locations for parts with unknown instock $this->addSql( '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 ' . - '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'); diff --git a/templates/Parts/info/_part_lots.html.twig b/templates/Parts/info/_part_lots.html.twig index 853dbf56..d7470a74 100644 --- a/templates/Parts/info/_part_lots.html.twig +++ b/templates/Parts/info/_part_lots.html.twig @@ -14,7 +14,13 @@