This commit is contained in:
Thomas Peterson 2025-07-18 12:01:18 +02:00
parent 9b14dedec0
commit 017a7931b3
2 changed files with 24 additions and 25 deletions

View File

@ -1,4 +1,5 @@
<?php
namespace PSC\Library\Calc\Option\Type;
use PSC\Library\Calc\Option\Type\Select\Opt;
@ -7,7 +8,7 @@ use PSC\Library\Calc\Tests\Mock\Paper;
class ColorDBSelect extends Select
{
private string $colorSystem = "";
private string $colorSystem = '';
public function getColorSystem(): string
{
@ -24,17 +25,16 @@ class ColorDBSelect extends Select
$obj = parent::generateJson();
$obj->mode = 'colordb';
$obj->container = $this->container;
$obj->options = [];
$obj->options[] = $this->getSelectedOption()->generateJson();
return $obj;
}
public function generateXML(): array
{
return array_merge_recursive(
parent::generateXML(),
['_attributes' => ['mode' => 'colordb', 'container' => $this->container]]);
return array_merge_recursive(parent::generateXML(), ['_attributes' => [
'mode' => 'colordb',
'container' => $this->container,
]]);
}
}

View File

@ -1,4 +1,5 @@
<?php
namespace PSC\Library\Calc\Option\Type;
use PSC\Library\Calc\Option\Type\Select\Opt;
@ -9,14 +10,16 @@ class PaperDbSelect extends Select
{
protected $newPaperObject = null;
public function getSelectedOption(): ?Opt
public function getSelectedOption(): null|Opt
{
if(count($this->selectedOptions) > 0) {
if (count($this->selectedOptions) > 0) {
return $this->selectedOptions[0];
}
if(isset($this->savedCalcValues[$this->getId()]) && $this->savedCalcValues[$this->getId()]['art_nr'] == $this->getRawValue()) {
if (
isset($this->savedCalcValues[$this->getId()]) &&
$this->savedCalcValues[$this->getId()]['art_nr'] == $this->getRawValue()
) {
$opt = new PaperOpt();
$opt->setId($this->savedCalcValues[$this->getId()]['art_nr']);
$opt->setLabel($this->savedCalcValues[$this->getId()]['description_1']);
@ -51,8 +54,7 @@ class PaperDbSelect extends Select
/** @var PaperOpt $option */
$option = $this->getSelectedOption();
if($option == null) {
if ($option == null) {
$variables[$this->getId() . '_grammatur'] = 0;
$variables[$this->getId() . '_art_nr'] = 0;
$variables[$this->getId() . '_volume'] = 0;
@ -102,9 +104,7 @@ class PaperDbSelect extends Select
$variables[$this->getId() . '_glam'] = 0;
$variables[$this->getId() . '_post'] = 0;
$variables[$this->getId() . '_sammelform'] = 0;
}else {
} else {
/** @var Paper $paper */
$paper = $option->getPaper();
@ -112,7 +112,7 @@ class PaperDbSelect extends Select
$variables[$this->getId() . '_art_nr'] = $paper->getArtNr();
$variables[$this->getId() . '_volume'] = $paper->getVolume();
$variables[$this->getId() . '_value'] = $paper->getPreis();
if($option->getValue() > 0) {
if ($option->getValue() > 0) {
$variables[$this->getId() . '_value'] = $option->getValue();
}
$variables[$this->getId() . '_offset_fix'] = $paper->getOffsetFix();
@ -160,7 +160,6 @@ class PaperDbSelect extends Select
$variables[$this->getId() . '_glam'] = $paper->getGlam();
$variables[$this->getId() . '_post'] = $paper->getPost();
$variables[$this->getId() . '_sammelform'] = $paper->getSammelform();
}
return $variables;
@ -176,19 +175,19 @@ class PaperDbSelect extends Select
public function generateXML(): array
{
return array_merge_recursive(
parent::generateXML(),
['_attributes' => ['mode' => 'papierdb', 'container' => $this->container]]);
return array_merge_recursive(parent::generateXML(), ['_attributes' => [
'mode' => 'papierdb',
'container' => $this->container,
]]);
}
public function generateJson(): \stdClass
{
$obj = parent::generateJson();
$obj->mode = 'papierdb';
$obj->container = $this->container;
$obj->options = [];
$obj->options[] = $this->getSelectedOption()->generateJson();
return $obj;
}
}