mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-20 17:15:51 +02:00
Added an admin page for currencies.
This commit is contained in:
parent
87e6f641c3
commit
2468409212
15 changed files with 374 additions and 9 deletions
|
@ -37,6 +37,8 @@
|
|||
"symfony/webpack-encore-bundle": "^1.1",
|
||||
"symfony/yaml": "4.3.*",
|
||||
"twig/extensions": "^1.5",
|
||||
"twig/extra-bundle": "3.x-dev",
|
||||
"twig/intl-extra": "3.x-dev",
|
||||
"webmozart/assert": "^1.4"
|
||||
},
|
||||
"require-dev": {
|
||||
|
|
116
composer.lock
generated
116
composer.lock
generated
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "c4b42f65037fd3b81886b8d9c98deb32",
|
||||
"content-hash": "4efee728068f5b14ad389d7a4a75131b",
|
||||
"packages": [
|
||||
{
|
||||
"name": "doctrine/annotations",
|
||||
|
@ -6371,6 +6371,118 @@
|
|||
],
|
||||
"time": "2018-12-05T18:34:18+00:00"
|
||||
},
|
||||
{
|
||||
"name": "twig/extra-bundle",
|
||||
"version": "3.x-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/twigphp/twig-extra-bundle.git",
|
||||
"reference": "695a3d1749265340642681fd48e30795752f7126"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/twigphp/twig-extra-bundle/zipball/695a3d1749265340642681fd48e30795752f7126",
|
||||
"reference": "695a3d1749265340642681fd48e30795752f7126",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"symfony/framework-bundle": "^4.3|^5.0",
|
||||
"symfony/twig-bundle": "^4.3|^5.0",
|
||||
"twig/twig": "^2.4|^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"twig/cssinliner-extra": "^2.12|^3.0@dev",
|
||||
"twig/html-extra": "^2.12@dev|^3.0@dev",
|
||||
"twig/inky-extra": "^2.12@dev|^3.0@dev",
|
||||
"twig/intl-extra": "^2.12@dev|^3.0@dev",
|
||||
"twig/markdown-extra": "^2.12@dev|^3.0@dev"
|
||||
},
|
||||
"type": "symfony-bundle",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Twig\\Extra\\TwigExtraBundle\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"role": "Lead Developer",
|
||||
"email": "fabien@symfony.com",
|
||||
"homepage": "http://fabien.potencier.org"
|
||||
}
|
||||
],
|
||||
"description": "A Symfony bundle for extra Twig extensions",
|
||||
"homepage": "https://twig.symfony.com",
|
||||
"keywords": [
|
||||
"bundle",
|
||||
"extra",
|
||||
"twig"
|
||||
],
|
||||
"time": "2019-08-12T07:27:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "twig/intl-extra",
|
||||
"version": "3.x-dev",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/twigphp/intl-extra.git",
|
||||
"reference": "6330d1cf99976605aa06c709fc382868b038ae9a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/twigphp/intl-extra/zipball/6330d1cf99976605aa06c709fc382868b038ae9a",
|
||||
"reference": "6330d1cf99976605aa06c709fc382868b038ae9a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.1.3",
|
||||
"symfony/intl": "^4.3",
|
||||
"twig/twig": "^2.4|^3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"symfony/phpunit-bridge": "^4.4@dev"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "3.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Twig\\Extra\\Intl\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Fabien Potencier",
|
||||
"role": "Lead Developer",
|
||||
"email": "fabien@symfony.com",
|
||||
"homepage": "http://fabien.potencier.org"
|
||||
}
|
||||
],
|
||||
"description": "A Twig extension for Intl",
|
||||
"homepage": "https://twig.symfony.com",
|
||||
"keywords": [
|
||||
"intl",
|
||||
"twig"
|
||||
],
|
||||
"time": "2019-08-12T07:27:28+00:00"
|
||||
},
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v2.11.3",
|
||||
|
@ -7526,6 +7638,8 @@
|
|||
"aliases": [],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": {
|
||||
"twig/extra-bundle": 20,
|
||||
"twig/intl-extra": 20,
|
||||
"roave/security-advisories": 20
|
||||
},
|
||||
"prefer-stable": false,
|
||||
|
|
|
@ -19,4 +19,5 @@ return [
|
|||
Shivas\VersioningBundle\ShivasVersioningBundle::class => ['all' => true],
|
||||
FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true],
|
||||
Translation\Bundle\TranslationBundle::class => ['all' => true],
|
||||
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
|
||||
];
|
||||
|
|
|
@ -6,3 +6,4 @@ twig:
|
|||
|
||||
globals:
|
||||
partdb_title: '%partdb_title%'
|
||||
default_currency: '%default_currency%'
|
||||
|
|
112
src/Controller/AdminPages/CurrencyController.php
Normal file
112
src/Controller/AdminPages/CurrencyController.php
Normal file
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* part-db version 0.1
|
||||
* Copyright (C) 2005 Christoph Lechner
|
||||
* http://www.cl-projects.de/
|
||||
*
|
||||
* part-db version 0.2+
|
||||
* Copyright (C) 2009 K. Jacobs and others (see authors.php)
|
||||
* http://code.google.com/p/part-db/
|
||||
*
|
||||
* Part-DB Version 0.4+
|
||||
* Copyright (C) 2016 - 2019 Jan Böhmer
|
||||
* https://github.com/jbtronics
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Controller\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Parts\Category;
|
||||
use App\Entity\PriceInformations\Currency;
|
||||
use App\Form\AdminPages\BaseEntityAdminForm;
|
||||
use App\Form\AdminPages\CategoryAdminForm;
|
||||
use App\Form\AdminPages\CurrencyAdminForm;
|
||||
use App\Services\EntityExporter;
|
||||
use App\Services\EntityImporter;
|
||||
use App\Services\StructuralElementRecursionHelper;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\Serializer\SerializerInterface;
|
||||
|
||||
/**
|
||||
* @Route("/currency")
|
||||
*
|
||||
* Class CurrencyController
|
||||
* @package App\Controller\AdminPages
|
||||
*/
|
||||
class CurrencyController extends BaseAdminController
|
||||
{
|
||||
protected $entity_class = Currency::class;
|
||||
protected $twig_template = 'AdminPages/CurrencyAdmin.html.twig';
|
||||
protected $form_class = CurrencyAdminForm::class;
|
||||
protected $route_base = "currency";
|
||||
|
||||
/**
|
||||
* @Route("/{id}/edit", requirements={"id"="\d+"}, name="currency_edit")
|
||||
* @Route("/{id}/", requirements={"id"="\d+"})
|
||||
*/
|
||||
public function edit(Currency $entity, Request $request, EntityManagerInterface $em)
|
||||
{
|
||||
return $this->_edit($entity, $request, $em);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/new", name="currency_new")
|
||||
* @Route("/")
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
*/
|
||||
public function new(Request $request, EntityManagerInterface $em, EntityImporter $importer)
|
||||
{
|
||||
return $this->_new($request, $em, $importer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}", name="currency_delete", methods={"DELETE"})
|
||||
*/
|
||||
public function delete(Request $request, Currency $entity, StructuralElementRecursionHelper $recursionHelper)
|
||||
{
|
||||
return $this->_delete($request, $entity, $recursionHelper);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/export", name="currency_export_all")
|
||||
* @param Request $request
|
||||
* @param SerializerInterface $serializer
|
||||
* @param EntityManagerInterface $em
|
||||
* @return Response
|
||||
*/
|
||||
public function exportAll(EntityManagerInterface $em, EntityExporter $exporter, Request $request)
|
||||
{
|
||||
return $this->_exportAll($em, $exporter, $request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{id}/export", name="currency_export")
|
||||
* @param Request $request
|
||||
* @param AttachmentType $entity
|
||||
*/
|
||||
public function exportEntity(Currency $entity, EntityExporter $exporter, Request $request)
|
||||
{
|
||||
return $this->_exportEntity($entity, $exporter, $request);
|
||||
}
|
||||
}
|
|
@ -69,6 +69,17 @@ class MeasurementUnit extends StructuralDBElement
|
|||
*/
|
||||
protected $usesSIPrefixes;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="MeasurementUnit", mappedBy="parent", cascade={"persist"})
|
||||
*/
|
||||
protected $children;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="MeasurementUnit", inversedBy="children")
|
||||
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* Returns the ID as an string, defined by the element class.
|
||||
* This should have a form like P000014, for a part with ID 14.
|
||||
|
|
|
@ -49,7 +49,7 @@ class Currency extends StructuralDBElement
|
|||
|
||||
/**
|
||||
* @var string The 3 letter ISO code of the currency.
|
||||
* @ORM\Column(type="string", unique=true, nullable=true)
|
||||
* @ORM\Column(type="string", unique=true)
|
||||
* @Assert\Currency()
|
||||
*/
|
||||
protected $iso_code;
|
||||
|
@ -57,16 +57,27 @@ class Currency extends StructuralDBElement
|
|||
/**
|
||||
* @var float|null The exchange rate between this currency and the base currency
|
||||
* (how many base units the current currency is worth)
|
||||
* @ORM\Column(type="decimal", precision=11, scale=5)
|
||||
* @ORM\Column(type="decimal", precision=11, scale=5, nullable=true)
|
||||
* @Assert\Positive()
|
||||
*/
|
||||
protected $exchange_rate;
|
||||
|
||||
/**
|
||||
* @ORM\OneToMany(targetEntity="Currency", mappedBy="parent", cascade={"persist"})
|
||||
*/
|
||||
protected $children;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Currency", inversedBy="children")
|
||||
* @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
|
||||
*/
|
||||
protected $parent;
|
||||
|
||||
/**
|
||||
* Returns the 3 letter ISO code of this currency
|
||||
* @return string
|
||||
*/
|
||||
public function getIsoCode(): string
|
||||
public function getIsoCode(): ?string
|
||||
{
|
||||
return $this->iso_code;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ use App\Entity\Base\NamedDBElement;
|
|||
use App\Entity\Base\StructuralDBElement;
|
||||
use FOS\CKEditorBundle\Form\Type\CKEditorType;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ContainerBagInterface;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ResetType;
|
||||
|
@ -48,10 +50,12 @@ class BaseEntityAdminForm extends AbstractType
|
|||
{
|
||||
|
||||
protected $security;
|
||||
protected $params;
|
||||
|
||||
public function __construct(Security $security)
|
||||
public function __construct(Security $security, ParameterBagInterface $params)
|
||||
{
|
||||
$this->security = $security;
|
||||
$this->params = $params;
|
||||
}
|
||||
|
||||
|
||||
|
@ -74,7 +78,7 @@ class BaseEntityAdminForm extends AbstractType
|
|||
'label' => 'not_selectable.label', 'help' => 'not_selectable.help', 'label_attr'=> ['class' => 'checkbox-custom'],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity) ])
|
||||
|
||||
->add('comment', CKEditorType::class, ['required' => false,
|
||||
->add('comment', CKEditorType::class, ['required' => false, 'empty_data' => '',
|
||||
'label' => 'comment.label', 'attr' => ['rows' => 4], 'help' => 'bbcode.hint',
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
|
||||
|
|
57
src/Form/AdminPages/CurrencyAdminForm.php
Normal file
57
src/Form/AdminPages/CurrencyAdminForm.php
Normal file
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* part-db version 0.1
|
||||
* Copyright (C) 2005 Christoph Lechner
|
||||
* http://www.cl-projects.de/
|
||||
*
|
||||
* part-db version 0.2+
|
||||
* Copyright (C) 2009 K. Jacobs and others (see authors.php)
|
||||
* http://code.google.com/p/part-db/
|
||||
*
|
||||
* Part-DB Version 0.4+
|
||||
* Copyright (C) 2016 - 2019 Jan Böhmer
|
||||
* https://github.com/jbtronics
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*
|
||||
*/
|
||||
|
||||
namespace App\Form\AdminPages;
|
||||
|
||||
|
||||
use App\Entity\Base\NamedDBElement;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CurrencyType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\MoneyType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
class CurrencyAdminForm extends BaseEntityAdminForm
|
||||
{
|
||||
protected function additionalFormElements(FormBuilderInterface $builder, array $options, NamedDBElement $entity)
|
||||
{
|
||||
$is_new = $entity->getID() === null;
|
||||
|
||||
$builder->add('iso_code', CurrencyType::class , ['required' => true,
|
||||
'label' => 'currency.iso_code.label',
|
||||
'preferred_choices' => ['EUR', 'USD', 'GBP', 'JPY', 'CNY'],
|
||||
'attr' => ['class' => 'selectpicker', 'data-live-search' => true],
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
|
||||
$builder->add('exchange_rate', MoneyType::class, ['required' => false,
|
||||
'label' => 'currency.exchange_rate.label', 'currency' => $this->params->get('default_currency'),
|
||||
'disabled' => !$this->security->isGranted($is_new ? 'create' : 'edit', $entity)]);
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ final class Version20190812154222 extends AbstractMigration
|
|||
|
||||
$this->addSql('CREATE TABLE `measurement_units` (id INT AUTO_INCREMENT NOT NULL, unit VARCHAR(255) NOT NULL, is_integer TINYINT(1) NOT NULL, use_si_prefix TINYINT(1) NOT NULL, comment LONGTEXT NOT NULL, parent_id INT DEFAULT NULL, not_selectable TINYINT(1) NOT NULL, name VARCHAR(255) NOT NULL, last_modified DATETIME NOT NULL, datetime_added DATETIME NOT NULL, UNIQUE INDEX UNIQ_F5AF83CFDCBB0C53 (unit), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE part_lots (id INT AUTO_INCREMENT NOT NULL, id_store_location INT DEFAULT NULL, id_part INT DEFAULT NULL, description LONGTEXT NOT NULL, comment LONGTEXT NOT NULL, expiration_date DATETIME DEFAULT NULL, instock_unknown TINYINT(1) NOT NULL, instock INT DEFAULT NULL, amount DOUBLE PRECISION DEFAULT NULL, needs_refill TINYINT(1) NOT NULL, last_modified DATETIME NOT NULL, datetime_added DATETIME NOT NULL, INDEX IDX_EBC8F9435D8F4B37 (id_store_location), INDEX IDX_EBC8F943C22F6CC4 (id_part), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE currencies (id INT AUTO_INCREMENT NOT NULL, iso_code VARCHAR(255) DEFAULT NULL, exchange_rate NUMERIC(11, 5) NOT NULL, comment LONGTEXT NOT NULL, parent_id INT DEFAULT NULL, not_selectable TINYINT(1) NOT NULL, name VARCHAR(255) NOT NULL, last_modified DATETIME NOT NULL, datetime_added DATETIME NOT NULL, UNIQUE INDEX UNIQ_37C4469362B6A45E (iso_code), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
|
||||
$this->addSql('CREATE TABLE currencies (id INT AUTO_INCREMENT NOT NULL, iso_code VARCHAR(255) NOT NULL, exchange_rate NUMERIC(11, 5) DEFAULT NULL, comment LONGTEXT NOT NULL, parent_id INT DEFAULT NULL, not_selectable TINYINT(1) NOT NULL, name VARCHAR(255) NOT NULL, last_modified DATETIME NOT NULL, datetime_added DATETIME NOT NULL, UNIQUE INDEX UNIQ_37C4469362B6A45E (iso_code), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB');
|
||||
$this->addSql('ALTER TABLE part_lots ADD CONSTRAINT FK_EBC8F9435D8F4B37 FOREIGN KEY (id_store_location) REFERENCES `storelocations` (id)');
|
||||
$this->addSql('ALTER TABLE part_lots ADD CONSTRAINT FK_EBC8F943C22F6CC4 FOREIGN KEY (id_part) REFERENCES `parts` (id)');
|
||||
|
||||
|
|
|
@ -33,12 +33,13 @@ namespace App\Security\Voter;
|
|||
|
||||
|
||||
use App\Entity\Attachments\AttachmentType;
|
||||
use App\Entity\Device\Device;
|
||||
use App\Entity\Devices\Device;
|
||||
use App\Entity\Parts\Category;
|
||||
use App\Entity\Parts\Footprint;
|
||||
use App\Entity\Parts\Manufacturer;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Entity\Parts\Supplier;
|
||||
use App\Entity\PriceInformations\Currency;
|
||||
use App\Entity\UserSystem\User;
|
||||
|
||||
class StructureVoter extends ExtendedVoter
|
||||
|
@ -83,6 +84,9 @@ class StructureVoter extends ExtendedVoter
|
|||
return 'storelocations';
|
||||
case Supplier::class:
|
||||
return 'suppliers';
|
||||
case Currency::class:
|
||||
//TODO: Implement own permission
|
||||
return 'suppliers';
|
||||
}
|
||||
//When the class is not supported by this class return null
|
||||
return null;
|
||||
|
|
|
@ -39,6 +39,7 @@ use App\Entity\Base\NamedDBElement;
|
|||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use App\Entity\Parts\Supplier;
|
||||
use App\Entity\PriceInformations\Currency;
|
||||
use App\Entity\UserSystem\User;
|
||||
use App\Exceptions\EntityNotSupported;
|
||||
use Symfony\Component\HttpKernel\HttpCache\Store;
|
||||
|
@ -176,10 +177,14 @@ class EntityURLGenerator
|
|||
return $this->urlGenerator->generate("footprint_edit", ['id' => $entity->getID()]);
|
||||
}
|
||||
|
||||
if($entity instanceof User) {
|
||||
if ($entity instanceof User) {
|
||||
return $this->urlGenerator->generate('user_edit', ['id' => $entity->getID()]);
|
||||
}
|
||||
|
||||
if ($entity instanceof Currency) {
|
||||
return $this->urlGenerator->generate('currency_edit', ['id' => $entity->getID()]);
|
||||
}
|
||||
|
||||
//Otherwise throw an error
|
||||
throw new EntityNotSupported('The given entity is not supported yet!');
|
||||
}
|
||||
|
@ -229,6 +234,10 @@ class EntityURLGenerator
|
|||
return $this->urlGenerator->generate('user_new');
|
||||
}
|
||||
|
||||
if ($entity instanceof Currency) {
|
||||
return $this->urlGenerator->generate('currency_new');
|
||||
}
|
||||
|
||||
throw new EntityNotSupported('The given entity is not supported yet!');
|
||||
}
|
||||
|
||||
|
@ -299,6 +308,10 @@ class EntityURLGenerator
|
|||
return $this->urlGenerator->generate('user_delete', ['id' => $entity->getID()]);
|
||||
}
|
||||
|
||||
if ($entity instanceof Currency) {
|
||||
return $this->urlGenerator->generate('currency_delete', ['id' => $entity->getID()]);
|
||||
}
|
||||
|
||||
throw new EntityNotSupported('The given entity is not supported yet!');
|
||||
}
|
||||
|
||||
|
|
|
@ -76,6 +76,9 @@ class ToolsTreeBuilder
|
|||
$nodes[] = new TreeViewNode($this->translator->trans('tree.tools.edit.footprint'),
|
||||
$this->urlGenerator->generate('footprint_new'));
|
||||
|
||||
$nodes[] = new TreeViewNode($this->translator->trans('tree.tools.edit.currency'),
|
||||
$this->urlGenerator->generate('currency_new'));
|
||||
|
||||
$nodes[] = new TreeViewNode($this->translator->trans('tree.tools.edit.part'),
|
||||
$this->urlGenerator->generate('part_new'));
|
||||
|
||||
|
|
|
@ -602,6 +602,12 @@
|
|||
"./config/packages/twig_extensions.yaml"
|
||||
]
|
||||
},
|
||||
"twig/extra-bundle": {
|
||||
"version": "3.x-dev"
|
||||
},
|
||||
"twig/intl-extra": {
|
||||
"version": "3.x-dev"
|
||||
},
|
||||
"twig/twig": {
|
||||
"version": "v2.6.2"
|
||||
},
|
||||
|
|
26
templates/AdminPages/CurrencyAdmin.html.twig
Normal file
26
templates/AdminPages/CurrencyAdmin.html.twig
Normal file
|
@ -0,0 +1,26 @@
|
|||
{% extends "AdminPages/EntityAdminBase.html.twig" %}
|
||||
|
||||
{% block card_title %}
|
||||
<i class="fas fa-file-alt fa-money-bill-alt"></i> {% trans %}currency.caption{% endtrans %}
|
||||
{% endblock %}
|
||||
|
||||
{% block additional_controls %}
|
||||
{{ form_row(form.iso_code) }}
|
||||
{% if entity.isoCode %}
|
||||
<div class="mt-0 mb-3">
|
||||
<span class="form-text text-muted offset-3 col-9">
|
||||
<b>{% trans %}currency.iso_code.caption{% endtrans %}:</b> {{ entity.isoCode }}
|
||||
</span>
|
||||
<span class="form-text text-muted offset-3 col-9">
|
||||
<b>{% trans %}currency.symbol.caption{% endtrans %}:</b> {{ entity.isoCode | currency_symbol }}
|
||||
</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{{ form_row(form.exchange_rate) }}
|
||||
{% if entity.inverseExchangeRate %}
|
||||
<span class="form-text text-muted offset-3 col-9">
|
||||
{{ '1'|format_currency(default_currency) }} = {{ entity.inverseExchangeRate | format_currency(entity.isoCode) }}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% endblock %}
|
Loading…
Add table
Add a link
Reference in a new issue