Kostenpositionen als Formular-Kapitel speichern

This commit is contained in:
gitea_admin committed 2026-09-20 12:06:20 +02:00
1 parent 6226f2a037
commit 313475afec
2 files changed
+24 -1

No files matched your search

+21
View File
@@ -98,6 +98,27 @@ if ($requestMethod === 'POST') {
market_management_set_occurrence_contact($pdo, $contactFields);
}
if ($fields !== []) {
$costItems = null;
if (array_key_exists('cost_items', $fields)) {
$costItems = is_string($fields['cost_items']) ? json_decode($fields['cost_items'], true) : $fields['cost_items'];
if (!is_array($costItems)) {
throw new InvalidArgumentException('Kostenpositionen sind ungültig.');
}
unset($fields['cost_items']);
foreach ($costItems as $costItem) {
if (!is_array($costItem)) {
throw new InvalidArgumentException('Kostenposition ist ungültig.');
}
if (isset($costItem['id'])) {
$costItemId = market_management_require_positive_id($costItem['id'], 'cost_item_id');
unset($costItem['id']);
market_management_update_cost_item($pdo, $costItemId, $costItem);
} else {
$costItem['occurrence_id'] = $id;
market_management_create_cost_item($pdo, $costItem);
}
}
}
market_management_update_occurrence($pdo, $id, $fields);
}
} else {