diff --git a/public/ckeditor/plugins/partdb_label/lang/de.js b/public/ckeditor/plugins/partdb_label/lang/de.js index d7599ddf..2a5818ba 100644 --- a/public/ckeditor/plugins/partdb_label/lang/de.js +++ b/public/ckeditor/plugins/partdb_label/lang/de.js @@ -23,6 +23,7 @@ CKEDITOR.plugins.setLang( 'partdb_label', 'de', { 'section.global': 'Global', 'section.part': 'Bauteil', 'section.part_lot': 'Bauteilbestand', + 'section.storelocation': 'Lagerort', 'part.id': 'Datenbank ID', 'part.name': 'Bauteilename', 'part.category': 'Kategorie', @@ -55,4 +56,14 @@ CKEDITOR.plugins.setLang( 'partdb_label', 'de', { 'lot.amount': 'Bestandsmenge', 'lot.location': 'Lagerort', 'lot.location_full': 'Lagerort (Ganzer Pfad)', + + 'storelocation.id': 'Lagerort ID', + 'storelocation.name': 'Name', + 'storelocation.full_path': 'Ganzer Pfad', + 'storelocation.parent_name': 'Name des Übergeordneten Elements', + 'storelocation.parent_full_path': 'Ganzer Pfad des Übergeordneten Elements', + 'storelocation.comment': 'Kommentar', + 'storelocation.comment_t': 'Kommentar (Text)', + 'storelocation.last_modified': 'Änderungsdatum', + 'storelocation.creation_date': 'Erstellungsdatum', } ); \ No newline at end of file diff --git a/public/ckeditor/plugins/partdb_label/lang/en.js b/public/ckeditor/plugins/partdb_label/lang/en.js index 42aa3b85..b26e9748 100644 --- a/public/ckeditor/plugins/partdb_label/lang/en.js +++ b/public/ckeditor/plugins/partdb_label/lang/en.js @@ -23,6 +23,7 @@ CKEDITOR.plugins.setLang( 'partdb_label', 'en', { 'section.global': 'Globals', 'section.part': 'Part', 'section.part_lot': 'Part lot', + 'section.storelocation': 'Storage location', 'part.id': 'Database ID', 'part.name': 'Part name', 'part.category': 'Category', @@ -55,4 +56,14 @@ CKEDITOR.plugins.setLang( 'partdb_label', 'en', { 'lot.amount': 'Lot amount', 'lot.location': 'Storage location', 'lot.location_full': 'Storage location (Full path)', + + 'storelocation.id': 'Location ID', + 'storelocation.name': 'Name', + 'storelocation.full_path': 'Full path', + 'storelocation.parent_name': 'Parent name', + 'storelocation.parent_full_path': 'Parent full path', + 'storelocation.comment': 'Comment', + 'storelocation.comment_t': 'Comment (Text)', + 'storelocation.last_modified': 'Last modified datetime', + 'storelocation.creation_date': 'Createion datetime', } ); \ No newline at end of file diff --git a/public/ckeditor/plugins/partdb_label/plugin.js b/public/ckeditor/plugins/partdb_label/plugin.js index a784254a..fd26bb42 100644 --- a/public/ckeditor/plugins/partdb_label/plugin.js +++ b/public/ckeditor/plugins/partdb_label/plugin.js @@ -57,6 +57,20 @@ const PLACEHOLDERS = { ['[[LOCATION_FULL]]', 'lot.location_full'], ] }, + storelocation: { + label: 'section.storelocation', + entries: [ + ['[[ID]]', 'storelocation.id'], + ['[[NAME]]', 'storelocation.name'], + ['[[FULL_PATH]]', 'storelocation.full_path'], + ['[[PARENT_NAME]]', 'storelocation.parent_name'], + ['[[PARENT_FULL_PATH]]', 'storelocation.parent_full_path'], + ['[[COMMENT]]', 'storelocation.comment'], + ['[[COMMENT_T]]', 'storelocation.comment_t'], + ['[[LAST_MODIFIED]]', 'storelocation.last_modified'], + ['[[CREATION_DATE]]', 'storelocation.creation_date'], + ] + }, global: { label: 'section.global', entries: [ diff --git a/src/Entity/LabelSystem/LabelOptions.php b/src/Entity/LabelSystem/LabelOptions.php index e2578193..8907169e 100644 --- a/src/Entity/LabelSystem/LabelOptions.php +++ b/src/Entity/LabelSystem/LabelOptions.php @@ -29,7 +29,7 @@ use Symfony\Component\Validator\Constraints as Assert; class LabelOptions { public const BARCODE_TYPES = ['none', /*'ean8',*/ 'qr', 'code39', 'datamatrix', 'code93', 'code128']; - public const SUPPORTED_ELEMENTS = ['part', 'part_lot']; + public const SUPPORTED_ELEMENTS = ['part', 'part_lot', 'storelocation']; public const PICTURE_TYPES = ['none', 'element_picture', 'main_attachment']; public const LINES_MODES = ['html', 'twig']; diff --git a/src/Form/LabelOptionsType.php b/src/Form/LabelOptionsType.php index fc99764a..9f35957e 100644 --- a/src/Form/LabelOptionsType.php +++ b/src/Form/LabelOptionsType.php @@ -65,7 +65,8 @@ class LabelOptionsType extends AbstractType 'label' => 'label_options.supported_elements.label', 'choices' => [ 'part.label' => 'part', - 'part_lot.label' => 'part_lot' + 'part_lot.label' => 'part_lot', + 'storelocation.label' => 'storelocation', ] ]); diff --git a/src/Services/LabelSystem/BarcodeExampleElementsGenerator.php b/src/Services/LabelSystem/BarcodeExampleElementsGenerator.php index e5e8f0d5..c78e1fb9 100644 --- a/src/Services/LabelSystem/BarcodeExampleElementsGenerator.php +++ b/src/Services/LabelSystem/BarcodeExampleElementsGenerator.php @@ -37,11 +37,28 @@ class BarcodeExampleElementsGenerator return $this->getExamplePart(); case 'part_lot': return $this->getExamplePartLot(); + case 'storelocation': + return $this->getStorelocation(); default: throw new \InvalidArgumentException('Unknown $type.'); } } + protected function getStorelocation(): Storelocation + { + $storelocation = new Storelocation(); + $storelocation->setName('Location 1'); + $storelocation->setComment('Example comment'); + $storelocation->updatedTimestamps(); + + $parent = new Storelocation(); + $parent->setName('Parent'); + + $storelocation->setParent($parent); + + return $storelocation; + } + protected function getStructuralData(string $class): AbstractStructuralDBElement { if (!is_a($class, AbstractStructuralDBElement::class, true)) { diff --git a/src/Services/LabelSystem/Barcodes/BarcodeContentGenerator.php b/src/Services/LabelSystem/Barcodes/BarcodeContentGenerator.php index 9fb49d33..7645523c 100644 --- a/src/Services/LabelSystem/Barcodes/BarcodeContentGenerator.php +++ b/src/Services/LabelSystem/Barcodes/BarcodeContentGenerator.php @@ -62,7 +62,7 @@ class BarcodeContentGenerator return $this->urlGenerator->generate('scan_qr', [ 'type' => $type, - 'id' => $target->getID(), + 'id' => $target->getID() ?? 0, '_locale' => null, ], UrlGeneratorInterface::ABSOLUTE_URL); } diff --git a/src/Services/LabelSystem/LabelGenerator.php b/src/Services/LabelSystem/LabelGenerator.php index 36f15985..e3bcf1f0 100644 --- a/src/Services/LabelSystem/LabelGenerator.php +++ b/src/Services/LabelSystem/LabelGenerator.php @@ -25,6 +25,7 @@ use App\Entity\Contracts\NamedElementInterface; use App\Entity\LabelSystem\LabelOptions; use App\Entity\Parts\Part; use App\Entity\Parts\PartLot; +use App\Entity\Parts\Storelocation; use App\Services\ElementTypeNameGenerator; use Dompdf\Dompdf; use Twig\Environment; @@ -34,6 +35,7 @@ class LabelGenerator public const CLASS_SUPPORT_MAPPING = [ 'part' => Part::class, 'part_lot' => PartLot::class, + 'storelocation' => Storelocation::class, ]; public const MM_TO_POINTS_FACTOR = 2.83465; diff --git a/src/Services/LabelSystem/PlaceholderProviders/StructuralDBElementProvider.php b/src/Services/LabelSystem/PlaceholderProviders/StructuralDBElementProvider.php new file mode 100644 index 00000000..f4fc50b8 --- /dev/null +++ b/src/Services/LabelSystem/PlaceholderProviders/StructuralDBElementProvider.php @@ -0,0 +1,52 @@ +. + */ + +namespace App\Services\LabelSystem\PlaceholderProviders; + + +use App\Entity\Base\AbstractDBElement; +use App\Entity\Base\AbstractStructuralDBElement; + +class StructuralDBElementProvider implements PlaceholderProviderInterface +{ + + public function replace(string $placeholder, object $label_target, array $options = []): ?string + { + if ($label_target instanceof AbstractStructuralDBElement) { + if ($placeholder === '[[COMMENT]]') { + return $label_target->getComment(); + } + if ($placeholder === '[[COMMENT_T]]') { + return strip_tags($label_target->getComment()); + } + if ($placeholder === '[[FULL_PATH]]') { + return $label_target->getFullPath(); + } + if ($placeholder === '[[PARENT]]') { + return $label_target->getParent() ? $label_target->getParent()->getName() : ''; + } + if ($placeholder === '[[PARENT_FULL_PATH]]') { + return $label_target->getParent() ? $label_target->getParent()->getFullPath() : ''; + } + } + + return null; + } +} \ No newline at end of file diff --git a/templates/AdminPages/StorelocationAdmin.html.twig b/templates/AdminPages/StorelocationAdmin.html.twig index 60bc95ba..57103a41 100644 --- a/templates/AdminPages/StorelocationAdmin.html.twig +++ b/templates/AdminPages/StorelocationAdmin.html.twig @@ -1,10 +1,18 @@ {% extends "AdminPages/EntityAdminBase.html.twig" %} +{% import "LabelSystem/dropdown_macro.html.twig" as dropdown %} {% block card_title %} {% trans %}storelocation.labelp{% endtrans %} {% endblock %} {% block additional_controls %} + {% if entity.id %} +