wip: continue implementation

This commit is contained in:
Björn Fromme
2024-12-02 17:38:56 +01:00
parent 84ab6446ea
commit 6f989d4c7a
24 changed files with 444 additions and 237 deletions
+9 -1
View File
@@ -2,10 +2,18 @@
namespace App\BusProNet\Model;
class Availability
class Availability implements \JsonSerializable
{
public ?int $serviceId = null;
public ?string $status = null;
public ?int $available = null;
public ?float $price = null;
public function jsonSerialize(): array
{
return [
'id' => $this->serviceId,
'available' => $this->available,
];
}
}
+12
View File
@@ -0,0 +1,12 @@
<?php
namespace App\BusProNet\Model;
class CrmAction
{
public ?int $id = null;
public ?string $code = null;
public ?string $label = null;
public bool $mutable = false;
public bool $selected = false;
}
+1 -21
View File
@@ -5,30 +5,10 @@ namespace App\BusProNet\Model;
class CrmAttributes
{
public ?array $selectionGroups = null;
public ?array $crmActions = null;
public bool $admin = false;
public bool $manager = false;
public bool $houseManager = false;
public bool $teamer = false;
public ?string $hotelCode = null;
public function toArray(): array
{
$crmSelections = [];
foreach ($this->selectionGroups as $group) {
/** @var CrmSelectionGroup $group */
if (false === isset($crmSelections[$group->label])) {
$crmSelections[$group->label] = [];
}
foreach ($group->selections as $attribute) {
/** @var CrmSelection $attribute */
if (false === $attribute->selected) {
continue;
}
$crmSelections[$group->label][] = $attribute->label;
}
}
return $crmSelections;
}
}
+1
View File
@@ -6,5 +6,6 @@ class CrmSelection
{
public ?int $id = null;
public ?string $label = null;
public bool $mutable = false;
public bool $selected = false;
}
+12
View File
@@ -19,4 +19,16 @@ class CrmSelectionGroup
public ?int $id = null;
public ?string $label = null;
public ?array $selections = null;
public function getMutableSelections(): array
{
return array_filter($this->selections, function (CrmSelection $selection) {
return $selection->mutable;
});
}
public function isVisible(): bool
{
return 0 < count($this->getMutableSelections());
}
}