mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-20 10:57:40 +02:00
Allow quantites in Orderdetails to be floats.
Useful for non integer based part units.
This commit is contained in:
parent
40889832ca
commit
b280d0c28b
7 changed files with 63 additions and 25 deletions
|
@ -31,6 +31,7 @@
|
|||
|
||||
namespace App\Form\Part;
|
||||
|
||||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Entity\Parts\Supplier;
|
||||
use App\Entity\PriceInformations\Orderdetail;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
|
@ -74,7 +75,10 @@ class OrderdetailType extends AbstractType
|
|||
'entry_type' => PricedetailType::class,
|
||||
'allow_add' => true, 'allow_delete' => true,
|
||||
'label' => false,
|
||||
'by_reference' => false
|
||||
'by_reference' => false,
|
||||
'entry_options' => [
|
||||
'measurement_unit' => $options['measurement_unit']
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -84,5 +88,8 @@ class OrderdetailType extends AbstractType
|
|||
'data_class' => Orderdetail::class,
|
||||
'error_bubbling' => false,
|
||||
]);
|
||||
|
||||
$resolver->setRequired('measurement_unit');
|
||||
$resolver->setAllowedTypes('measurement_unit', [MeasurementUnit::class, 'null']);
|
||||
}
|
||||
}
|
|
@ -150,6 +150,9 @@ class PartBaseType extends AbstractType
|
|||
'allow_add' => true, 'allow_delete' => true,
|
||||
'label' => false,
|
||||
'by_reference' => false,
|
||||
'entry_options' => [
|
||||
'measurement_unit' => $part->getPartUnit()
|
||||
]
|
||||
]);
|
||||
|
||||
$builder
|
||||
|
|
|
@ -32,10 +32,12 @@
|
|||
namespace App\Form\Part;
|
||||
|
||||
|
||||
use App\Entity\Parts\MeasurementUnit;
|
||||
use App\Entity\PriceInformations\Currency;
|
||||
use App\Entity\PriceInformations\Orderdetail;
|
||||
use App\Entity\PriceInformations\Pricedetail;
|
||||
use App\Form\Type\CurrencyEntityType;
|
||||
use App\Form\Type\SIUnitType;
|
||||
use App\Form\Type\StructuralEntityType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
|
||||
|
@ -48,11 +50,13 @@ class PricedetailType extends AbstractType
|
|||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
//No labels needed, we define translation in templates
|
||||
$builder->add("min_discount_quantity", IntegerType::class, [
|
||||
'attr' => ['min' => 1]
|
||||
$builder->add("min_discount_quantity", SIUnitType::class, [
|
||||
'measurement_unit' => $options['measurement_unit'],
|
||||
'attr' => ['class' => 'form-control-sm']
|
||||
]);
|
||||
$builder->add("price_related_quantity", IntegerType::class, [
|
||||
'attr' => ['min' => 1]
|
||||
$builder->add("price_related_quantity", SIUnitType::class, [
|
||||
'measurement_unit' => $options['measurement_unit'],
|
||||
'attr' => ['class' => 'form-control-sm']
|
||||
]);
|
||||
$builder->add("price", NumberType::class);
|
||||
$builder->add("currency", CurrencyEntityType::class, ['required' => false]);
|
||||
|
@ -64,5 +68,8 @@ class PricedetailType extends AbstractType
|
|||
'data_class' => Pricedetail::class,
|
||||
'error_bubbling' => false
|
||||
]);
|
||||
|
||||
$resolver->setRequired('measurement_unit');
|
||||
$resolver->setAllowedTypes('measurement_unit', [MeasurementUnit::class, 'null']);
|
||||
}
|
||||
}
|
|
@ -126,6 +126,13 @@ class SIUnitType extends AbstractType implements DataMapperInterface
|
|||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
{
|
||||
$view->vars['sm'] = false;
|
||||
|
||||
//Check if we need to make this thing small
|
||||
if (isset($options['attr']['class'])) {
|
||||
$view->vars['sm'] = (strpos($options['attr']['class'], 'form-control-sm') !== false);
|
||||
}
|
||||
|
||||
$view->vars['unit'] = $options['unit'];
|
||||
parent::buildView($view, $form, $options); // TODO: Change the autogenerated stub
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue