Veranstalter am Markt verankern

This commit is contained in:
gitea_admin committed 2026-09-20 10:57:40 +02:00
1 parent ba36485180
commit 0e71aca89b
10 files changed
+271 -106

No files matched your search

+18 -35
View File
@@ -51,7 +51,7 @@ function market_management_mcp_tools(): array
'travel_notes' => ['type' => ['string', 'null']], 'cancellation_terms' => ['type' => ['string', 'null']],
'revenue_share_terms' => ['type' => ['string', 'null']], 'other_participation_conditions' => ['type' => ['string', 'null']],
'contract_folder_url' => ['type' => ['string', 'null'], 'format' => 'uri'],
'organization_contact_id' => ['type' => ['integer', 'null']], 'contact_person_id' => ['type' => ['integer', 'null']],
'contact_person_name' => ['type' => ['string', 'null']],
'contact_email' => ['type' => ['string', 'null'], 'format' => 'email'], 'contact_phone' => ['type' => ['string', 'null']],
];
$dayProperties = [
@@ -73,11 +73,13 @@ function market_management_mcp_tools(): array
['name' => 'market_management.search_markets', 'description' => 'Märkte suchen', 'inputSchema' => ['type' => 'object', 'properties' => $searchProperties]],
['name' => 'market_management.search_occurrences', 'description' => 'Marktdurchführungen suchen und auflisten', 'inputSchema' => ['type' => 'object', 'properties' => $searchProperties]],
['name' => 'market_management.get_market', 'description' => 'Markt mit Marktdurchführungen lesen', 'inputSchema' => ['type' => 'object', 'required' => ['market_id'], 'properties' => ['market_id' => ['type' => 'integer'], 'include_archived' => ['type' => 'boolean']]]],
['name' => 'market_management.create_market', 'description' => 'Markt mit bestehender Kategorie und optionaler Website-URL anlegen', 'inputSchema' => ['type' => 'object', 'required' => ['name', 'category_id'], 'properties' => ['name' => ['type' => 'string'], 'category_id' => ['type' => 'integer'], 'website_url' => ['type' => ['string', 'null'], 'format' => 'uri']]]],
['name' => 'market_management.update_market', 'description' => 'Markt inklusive Website-URL ändern', 'inputSchema' => ['type' => 'object', 'required' => ['market_id'], 'properties' => ['market_id' => ['type' => 'integer'], 'name' => ['type' => 'string'], 'category_id' => ['type' => 'integer'], 'website_url' => ['type' => ['string', 'null'], 'format' => 'uri']]]],
['name' => 'market_management.create_market', 'description' => 'Markt mit verpflichtendem Veranstalter, Kategorie und optionaler Website-URL anlegen', 'inputSchema' => ['type' => 'object', 'required' => ['name', 'category_id', 'organizer_party_id'], 'properties' => ['name' => ['type' => 'string'], 'category_id' => ['type' => 'integer'], 'organizer_party_id' => ['type' => 'integer'], 'website_url' => ['type' => ['string', 'null'], 'format' => 'uri']]]],
['name' => 'market_management.update_market', 'description' => 'Markt inklusive Veranstalter und Website-URL ändern', 'inputSchema' => ['type' => 'object', 'required' => ['market_id'], 'properties' => ['market_id' => ['type' => 'integer'], 'name' => ['type' => 'string'], 'category_id' => ['type' => 'integer'], 'organizer_party_id' => ['type' => 'integer'], 'website_url' => ['type' => ['string', 'null'], 'format' => 'uri']]]],
['name' => 'market_management.archive_market', 'description' => 'Markt archivieren', 'inputSchema' => ['type' => 'object', 'required' => ['market_id'], 'properties' => ['market_id' => ['type' => 'integer']]]],
['name' => 'market_management.reactivate_market', 'description' => 'Markt reaktivieren', 'inputSchema' => ['type' => 'object', 'required' => ['market_id'], 'properties' => ['market_id' => ['type' => 'integer']]]],
['name' => 'market_management.list_categories', 'description' => 'Bestehende Kategorien lesen', 'inputSchema' => ['type' => 'object', 'properties' => []]],
['name' => 'market_management.list_market_organizers', 'description' => 'Aktive Veranstalter lesen', 'inputSchema' => ['type' => 'object', 'properties' => []]],
['name' => 'market_management.create_market_organizer', 'description' => 'Veranstalter mit optionalen Kontaktdaten anlegen', 'inputSchema' => ['type' => 'object', 'required' => ['name'], 'properties' => ['name' => ['type' => 'string'], 'email' => ['type' => ['string', 'null'], 'format' => 'email'], 'phone' => ['type' => ['string', 'null']]]]],
['name' => 'market_management.list_reference_data', 'description' => 'Kategorien, Kantone und Gemeinden lesen', 'inputSchema' => ['type' => 'object', 'properties' => []]],
['name' => 'market_management.get_overview', 'description' => 'Marktübersicht mit serverseitigen Filtern lesen', 'inputSchema' => ['type' => 'object', 'properties' => $searchProperties]],
['name' => 'market_management.create_occurrence', 'description' => 'Marktdurchführung mit mindestens einem Markttag anlegen', 'inputSchema' => ['type' => 'object', 'required' => ['market_definition_id', 'days'], 'properties' => ['market_definition_id' => ['type' => 'integer'], 'status' => ['type' => 'string'], 'days' => ['type' => 'array', 'minItems' => 1, 'items' => ['type' => 'object', 'required' => ['date'], 'properties' => $dayProperties]] + $occurrenceProperties]]],
@@ -88,8 +90,6 @@ function market_management_mcp_tools(): array
['name' => 'market_management.create_day', 'description' => 'Markttag anlegen', 'inputSchema' => ['type' => 'object', 'required' => ['occurrence_id', 'date'], 'properties' => ['occurrence_id' => ['type' => 'integer']] + $dayProperties]],
['name' => 'market_management.update_day', 'description' => 'Markttag ändern', 'inputSchema' => ['type' => 'object', 'required' => ['day_id'], 'properties' => ['day_id' => ['type' => 'integer']] + $dayProperties]],
['name' => 'market_management.delete_day', 'description' => 'Markttag entfernen', 'inputSchema' => ['type' => 'object', 'required' => ['day_id'], 'properties' => ['day_id' => ['type' => 'integer']]]],
['name' => 'market_management.set_organizer', 'description' => 'Veranstalter einer Marktdurchführung setzen', 'inputSchema' => ['type' => 'object', 'required' => ['occurrence_id', 'organization_contact_id', 'contact_person_id'], 'properties' => ['occurrence_id' => ['type' => 'integer'], 'organization_contact_id' => ['type' => 'integer'], 'contact_person_id' => ['type' => 'integer']]]],
['name' => 'market_management.delete_organizer', 'description' => 'Veranstalter einer Marktdurchführung entfernen', 'inputSchema' => ['type' => 'object', 'required' => ['occurrence_id'], 'properties' => ['occurrence_id' => ['type' => 'integer']]]],
['name' => 'market_management.create_cost_item', 'description' => 'Kostenposition anlegen', 'inputSchema' => ['type' => 'object', 'required' => ['occurrence_id', 'cost_type', 'gross_amount', 'tax_status'], 'properties' => ['occurrence_id' => ['type' => 'integer'], 'cost_type' => ['type' => 'string'], 'description' => ['type' => ['string', 'null']], 'gross_amount' => ['type' => 'number'], 'tax_status' => ['type' => 'string', 'enum' => ['tax_free', 'taxable']], 'tax_rate' => ['type' => 'number']]]],
['name' => 'market_management.update_cost_item', 'description' => 'Kostenposition ändern', 'inputSchema' => ['type' => 'object', 'required' => ['cost_item_id'], 'properties' => ['cost_item_id' => ['type' => 'integer'], 'cost_type' => ['type' => 'string'], 'description' => ['type' => ['string', 'null']], 'gross_amount' => ['type' => ['number', 'null']], 'tax_status' => ['type' => ['string', 'null'], 'enum' => ['tax_free', 'taxable']], 'tax_rate' => ['type' => ['number', 'null']]]]],
['name' => 'market_management.delete_cost_item', 'description' => 'Kostenposition entfernen', 'inputSchema' => ['type' => 'object', 'required' => ['cost_item_id'], 'properties' => ['cost_item_id' => ['type' => 'integer']]]],
@@ -100,11 +100,11 @@ function market_management_mcp_is_write_tool(string $tool): bool
{
return in_array($tool, [
'market_management.create_market', 'market_management.update_market',
'market_management.create_market_organizer',
'market_management.archive_market', 'market_management.reactivate_market',
'market_management.create_occurrence', 'market_management.update_occurrence',
'market_management.archive_occurrence', 'market_management.reactivate_occurrence',
'market_management.create_day', 'market_management.update_day', 'market_management.delete_day',
'market_management.set_organizer', 'market_management.delete_organizer',
'market_management.create_cost_item', 'market_management.update_cost_item',
'market_management.delete_cost_item',
], true);
@@ -218,41 +218,22 @@ function market_management_mcp_get_market(PDO $pdo, int $marketId, bool $include
function market_management_mcp_update_occurrence(PDO $pdo, int $occurrenceId, array $input): array
{
$contactFields = [];
foreach (['contact_email', 'contact_phone'] as $field) {
foreach (['contact_person_name', 'contact_email', 'contact_phone'] as $field) {
if (array_key_exists($field, $input)) {
$contactFields[substr($field, 8)] = $input[$field];
unset($input[$field]);
}
}
$organizerFields = [];
foreach (['organization_contact_id', 'contact_person_id'] as $field) {
if (array_key_exists($field, $input)) {
$organizerFields[$field] = $input[$field];
$contactFields[$field] = $input[$field];
unset($input[$field]);
}
}
$existing = null;
if ($contactFields !== [] || $organizerFields !== []) {
if ($contactFields !== []) {
$existing = market_management_get_occurrence($pdo, $occurrenceId, true);
if ($existing === null) {
throw new RuntimeException('Marktdurchführung nicht gefunden.');
}
}
if ($organizerFields !== []) {
$organizer = $existing['organizer'] ?? [];
$organizerFields['occurrence_id'] = $occurrenceId;
$organizerFields['organization_contact_id'] ??= $organizer['organization_contact_id'] ?? null;
$organizerFields['contact_person_id'] ??= $organizer['contact_person_id'] ?? null;
market_management_set_organizer($pdo, $organizerFields);
}
if ($contactFields !== []) {
$contactId = (int) ($organizerFields['contact_person_id'] ?? $existing['contact_person_id'] ?? 0);
$hasContactValue = array_reduce($contactFields, static fn (bool $carry, mixed $value): bool => $carry || trim((string) $value) !== '', false);
if ($contactId > 0 && ($hasContactValue || array_key_exists('contact_person_id', $organizerFields))) {
update_contact_details($pdo, $contactId, $contactFields);
} elseif ($hasContactValue) {
throw new InvalidArgumentException('Für E-Mail oder Telefon muss eine Kontaktperson ausgewählt sein.');
}
$contactFields['occurrence_id'] = $occurrenceId;
market_management_set_occurrence_contact($pdo, $contactFields);
}
if ($input !== []) {
market_management_update_occurrence($pdo, $occurrenceId, $input);
@@ -287,6 +268,13 @@ function market_management_mcp_call(PDO $pdo, string $tool, array $arguments): a
false
),
'market_management.list_categories' => market_management_list_categories($pdo),
'market_management.list_market_organizers' => get_market_organizer_options($pdo),
'market_management.create_market_organizer' => create_market_organizer(
$pdo,
(string) ($arguments['name'] ?? ''),
$arguments['email'] ?? null,
$arguments['phone'] ?? null
),
'market_management.list_reference_data' => market_management_list_reference_data($pdo, $arguments),
'market_management.get_overview' => [
'markets' => market_management_search_markets($pdo, $arguments),
@@ -323,11 +311,6 @@ function market_management_mcp_call(PDO $pdo, string $tool, array $arguments): a
$pdo,
market_management_require_positive_id($arguments['day_id'] ?? null, 'day_id')
),
'market_management.set_organizer' => market_management_set_organizer($pdo, $arguments),
'market_management.delete_organizer' => market_management_delete_organizer(
$pdo,
market_management_require_positive_id($arguments['occurrence_id'] ?? null, 'occurrence_id')
),
'market_management.create_cost_item' => market_management_create_cost_item($pdo, $arguments),
'market_management.update_cost_item' => market_management_update_cost_item(
$pdo,