mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-25 03:08:51 +02:00
Apply the default currency value to pricedetails placeholder.
This commit is contained in:
parent
8153a922f0
commit
42399b5517
3 changed files with 37 additions and 10 deletions
|
@ -205,6 +205,10 @@ class Orderdetail extends DBElement
|
||||||
return $this->supplier_product_url;
|
return $this->supplier_product_url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->supplier === null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
return $this->getSupplier()->getAutoProductUrl($this->supplierpartnr); // maybe an automatic url is available...
|
return $this->getSupplier()->getAutoProductUrl($this->supplierpartnr); // maybe an automatic url is available...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ namespace App\Form\Part;
|
||||||
use App\Entity\Parts\MeasurementUnit;
|
use App\Entity\Parts\MeasurementUnit;
|
||||||
use App\Entity\Parts\Supplier;
|
use App\Entity\Parts\Supplier;
|
||||||
use App\Entity\PriceInformations\Orderdetail;
|
use App\Entity\PriceInformations\Orderdetail;
|
||||||
|
use App\Entity\PriceInformations\Pricedetail;
|
||||||
use App\Form\Type\StructuralEntityType;
|
use App\Form\Type\StructuralEntityType;
|
||||||
use Symfony\Component\Form\AbstractType;
|
use Symfony\Component\Form\AbstractType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||||
|
@ -41,12 +42,18 @@ use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
||||||
use Symfony\Component\Form\FormBuilderInterface;
|
use Symfony\Component\Form\FormBuilderInterface;
|
||||||
|
use Symfony\Component\Form\FormEvent;
|
||||||
|
use Symfony\Component\Form\FormEvents;
|
||||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||||
|
use function foo\func;
|
||||||
|
|
||||||
class OrderdetailType extends AbstractType
|
class OrderdetailType extends AbstractType
|
||||||
{
|
{
|
||||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||||
{
|
{
|
||||||
|
/** @var Orderdetail $orderdetail */
|
||||||
|
$orderdetail = $builder->getData();
|
||||||
|
|
||||||
$builder->add('supplierpartnr', TextType::class, [
|
$builder->add('supplierpartnr', TextType::class, [
|
||||||
'label' => 'orderdetails.edit.supplierpartnr',
|
'label' => 'orderdetails.edit.supplierpartnr',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
|
@ -70,16 +77,30 @@ class OrderdetailType extends AbstractType
|
||||||
'label' => 'orderdetails.edit.obsolete'
|
'label' => 'orderdetails.edit.obsolete'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
//Add pricedetails after we know the data, so we can set the default currency
|
||||||
|
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options) {
|
||||||
|
/** @var Orderdetail $orderdetail */
|
||||||
|
$orderdetail = $event->getData();
|
||||||
|
|
||||||
|
$dummy_pricedetail = new Pricedetail();
|
||||||
|
if ($orderdetail->getSupplier() !== null) {
|
||||||
|
$dummy_pricedetail->setCurrency($orderdetail->getSupplier()->getDefaultCurrency());
|
||||||
|
}
|
||||||
|
|
||||||
//Attachment section
|
//Attachment section
|
||||||
$builder->add('pricedetails', CollectionType::class, [
|
$event->getForm()->add('pricedetails', CollectionType::class, [
|
||||||
'entry_type' => PricedetailType::class,
|
'entry_type' => PricedetailType::class,
|
||||||
'allow_add' => true, 'allow_delete' => true,
|
'allow_add' => true, 'allow_delete' => true,
|
||||||
'label' => false,
|
'label' => false,
|
||||||
|
'prototype_data' => $dummy_pricedetail,
|
||||||
'by_reference' => false,
|
'by_reference' => false,
|
||||||
'entry_options' => [
|
'entry_options' => [
|
||||||
'measurement_unit' => $options['measurement_unit']
|
'measurement_unit' => $options['measurement_unit']
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configureOptions(OptionsResolver $resolver)
|
public function configureOptions(OptionsResolver $resolver)
|
||||||
|
|
|
@ -38,6 +38,7 @@ use App\Entity\Parts\Manufacturer;
|
||||||
use App\Entity\Parts\MeasurementUnit;
|
use App\Entity\Parts\MeasurementUnit;
|
||||||
use App\Entity\Parts\Part;
|
use App\Entity\Parts\Part;
|
||||||
use App\Entity\Parts\Storelocation;
|
use App\Entity\Parts\Storelocation;
|
||||||
|
use App\Entity\PriceInformations\Orderdetail;
|
||||||
use App\Form\AttachmentFormType;
|
use App\Form\AttachmentFormType;
|
||||||
use App\Form\AttachmentType;
|
use App\Form\AttachmentType;
|
||||||
use App\Form\Type\SIUnitType;
|
use App\Form\Type\SIUnitType;
|
||||||
|
@ -150,6 +151,7 @@ class PartBaseType extends AbstractType
|
||||||
'allow_add' => true, 'allow_delete' => true,
|
'allow_add' => true, 'allow_delete' => true,
|
||||||
'label' => false,
|
'label' => false,
|
||||||
'by_reference' => false,
|
'by_reference' => false,
|
||||||
|
'prototype_data' => new Orderdetail(),
|
||||||
'entry_options' => [
|
'entry_options' => [
|
||||||
'measurement_unit' => $part->getPartUnit()
|
'measurement_unit' => $part->getPartUnit()
|
||||||
]
|
]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue