Complete market overview card editing
This commit is contained in:
1 parent
94d336f090
commit
6a12a43114
4 files changed
+62
-4
No files matched your search
@@ -39,6 +39,31 @@ if ($requestMethod === 'POST') {
|
||||
if ($scope === 'day') {
|
||||
market_management_update_day($pdo, $id, $fields);
|
||||
} elseif (in_array($scope, ['occurrence', 'status', 'overview', 'participation', 'infrastructure', 'travel', 'notes'], true)) {
|
||||
$marketFields = [];
|
||||
foreach (['market_name', 'category_id', 'website_url'] as $marketField) {
|
||||
if (array_key_exists($marketField, $fields)) {
|
||||
$marketFields[$marketField === 'market_name' ? 'name' : $marketField] = $fields[$marketField];
|
||||
unset($fields[$marketField]);
|
||||
}
|
||||
}
|
||||
$contactFields = [];
|
||||
foreach (['contact_email', 'contact_phone'] as $contactField) {
|
||||
if (array_key_exists($contactField, $fields)) {
|
||||
$contactFields[substr($contactField, 8)] = $fields[$contactField];
|
||||
unset($fields[$contactField]);
|
||||
}
|
||||
}
|
||||
$existingOccurrence = null;
|
||||
if ($marketFields !== [] || $contactFields !== [] || array_key_exists('organization_contact_id', $fields) || array_key_exists('contact_person_id', $fields)) {
|
||||
$existingOccurrence = market_management_get_occurrence($pdo, $id, true);
|
||||
}
|
||||
if ($marketFields !== []) {
|
||||
market_management_update_market($pdo, (int) ($existingOccurrence['market_definition_id'] ?? 0), $marketFields);
|
||||
}
|
||||
if ($contactFields !== []) {
|
||||
$contactId = (int) ($fields['contact_person_id'] ?? $existingOccurrence['contact_person_id'] ?? 0);
|
||||
update_contact_details($pdo, $contactId, $contactFields);
|
||||
}
|
||||
$organizerFields = [];
|
||||
foreach (['organization_contact_id', 'contact_person_id'] as $organizerField) {
|
||||
if (array_key_exists($organizerField, $fields)) {
|
||||
@@ -47,7 +72,7 @@ if ($requestMethod === 'POST') {
|
||||
}
|
||||
}
|
||||
if ($organizerFields !== []) {
|
||||
$existingOccurrence = market_management_get_occurrence($pdo, $id, true);
|
||||
$existingOccurrence ??= market_management_get_occurrence($pdo, $id, true);
|
||||
$existingOrganizer = $existingOccurrence['organizer'] ?? null;
|
||||
$organizerFields['occurrence_id'] = $id;
|
||||
$organizerFields['organization_contact_id'] ??= $existingOrganizer['organization_contact_id'] ?? null;
|
||||
|
||||
Reference in new issue
Block a user