mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-01-14 06:09:33 +00:00
Projekt BOM-Konfiguration um Assemblies bereinigen.
Assembly BOM-Konfiguration um Projektauswahl erweitern (APS-3, APS-4)
This commit is contained in:
parent
df85017efb
commit
adbe310d7f
53 changed files with 739 additions and 1506 deletions
|
|
@ -8,6 +8,7 @@ use App\Entity\AssemblySystem\AssemblyBOMEntry;
|
|||
use App\Form\Type\BigDecimalNumberType;
|
||||
use App\Form\Type\CurrencyEntityType;
|
||||
use App\Form\Type\PartSelectType;
|
||||
use App\Form\Type\ProjectSelectType;
|
||||
use App\Form\Type\RichTextEditorType;
|
||||
use App\Form\Type\SIUnitType;
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
|
|
@ -34,11 +35,13 @@ class AssemblyBOMEntryType extends AbstractType
|
|||
});
|
||||
|
||||
$builder
|
||||
|
||||
->add('part', PartSelectType::class, [
|
||||
'required' => false,
|
||||
])
|
||||
|
||||
->add('project', ProjectSelectType::class, [
|
||||
'label' => 'assembly.bom.project',
|
||||
'required' => false,
|
||||
])
|
||||
->add('name', TextType::class, [
|
||||
'label' => 'assembly.bom.name',
|
||||
'required' => false,
|
||||
|
|
@ -75,10 +78,8 @@ class AssemblyBOMEntryType extends AbstractType
|
|||
'required' => false,
|
||||
'label' => false,
|
||||
'short' => true,
|
||||
])
|
||||
|
||||
;
|
||||
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void
|
||||
|
|
|
|||
|
|
@ -78,35 +78,34 @@ class AssemblyBuildType extends AbstractType implements DataMapperInterface
|
|||
'required' => false,
|
||||
]);
|
||||
|
||||
|
||||
//The form is initially empty, we have to define the fields after we know the data
|
||||
//The form is initially empty, define the fields after we know the data
|
||||
$builder->addEventListener(FormEvents::PRE_SET_DATA, function (PreSetDataEvent $event) {
|
||||
$form = $event->getForm();
|
||||
/** @var AssemblyBuildRequest $build_request */
|
||||
$build_request = $event->getData();
|
||||
/** @var AssemblyBuildRequest $assemblyBuildRequest */
|
||||
$assemblyBuildRequest = $event->getData();
|
||||
|
||||
$form->add('addBuildsToBuildsPart', CheckboxType::class, [
|
||||
'label' => 'assembly.build.add_builds_to_builds_part',
|
||||
'required' => false,
|
||||
'disabled' => !$build_request->getAssembly()->getBuildPart() instanceof Part,
|
||||
'disabled' => !$assemblyBuildRequest->getAssembly()->getBuildPart() instanceof Part,
|
||||
]);
|
||||
|
||||
if ($build_request->getAssembly()->getBuildPart() instanceof Part) {
|
||||
if ($assemblyBuildRequest->getAssembly()->getBuildPart() instanceof Part) {
|
||||
$form->add('buildsPartLot', PartLotSelectType::class, [
|
||||
'label' => 'assembly.build.builds_part_lot',
|
||||
'required' => false,
|
||||
'part' => $build_request->getAssembly()->getBuildPart(),
|
||||
'part' => $assemblyBuildRequest->getAssembly()->getBuildPart(),
|
||||
'placeholder' => 'assembly.build.buildsPartLot.new_lot'
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($build_request->getPartBomEntries() as $bomEntry) {
|
||||
foreach ($assemblyBuildRequest->getPartBomEntries() as $bomEntry) {
|
||||
//Every part lot has a field to specify the number of parts to take from this lot
|
||||
foreach ($build_request->getPartLotsForBOMEntry($bomEntry) as $lot) {
|
||||
foreach ($assemblyBuildRequest->getPartLotsForBOMEntry($bomEntry) as $lot) {
|
||||
$form->add('lot_' . $lot->getID(), SIUnitType::class, [
|
||||
'label' => false,
|
||||
'measurement_unit' => $bomEntry->getPart()->getPartUnit(),
|
||||
'max' => min($build_request->getNeededAmountForBOMEntry($bomEntry), $lot->getAmount()),
|
||||
'max' => min($assemblyBuildRequest->getNeededAmountForBOMEntry($bomEntry), $lot->getAmount()),
|
||||
'disabled' => !$this->security->isGranted('withdraw', $lot),
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue