'; $out .= '

Association Profile — Management

'; $out .= '
'; $out .= 'Add Association'; $out .= 'Manage Fields'; $out .= '
'; if (empty($registry)) { $out .= '

No associations registered.

'; } else { $out .= ''; $out .= ''; foreach ($registry as $slug => $entry) { $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; } $out .= '
SlugLegal NameTypeUnitsUpdated
' . assoc_h($slug) . '' . assoc_h($entry['assoc_legal_name'] ?? '—') . '' . assoc_h($entry['assoc_type'] ?? '—') . '' . assoc_h($entry['assoc_units'] ?? '—') . '' . assoc_h($entry['assoc_updated'] ?? '—') . 'Edit
'; } $out .= ''; return $out; } function assoc_render_add_association_form() { $out = '
'; $out .= '

Add Association

'; $out .= '
'; $out .= assoc_csrf_token(); $out .= ''; $out .= '
'; $out .= ''; $out .= ''; $out .= '
'; $out .= ' '; $out .= 'Cancel'; $out .= '
'; return $out; } function assoc_render_edit_association_form($slug) { $registry = assoc_load_registry(); if (!isset($registry[$slug])) { return '
Association not found: ' . assoc_h($slug) . '
'; } $entry = $registry[$slug]; $def = assoc_load_fields(); $groups = $def['groups'] ?? []; $fields = $def['fields'] ?? []; $by_group = []; foreach ($fields as $f) { $by_group[$f['group']][] = $f; } $out = '
'; $out .= '

' . assoc_h($entry['assoc_legal_name'] ?? $slug) . '

'; $out .= '

' . assoc_h($slug) . '

'; $out .= '
'; $out .= assoc_csrf_token(); $out .= ''; $out .= ''; foreach ($groups as $group) { $group_fields = $by_group[$group] ?? []; if (empty($group_fields)) continue; $out .= '
' . assoc_h($group) . '
'; foreach ($group_fields as $f) { $nick = $f['nickname']; $val = $entry[$nick] ?? ($f['default'] ?? ''); $type = $f['type'] ?? 'text'; $label = $f['label'] ?? $nick; $help = $f['help'] ?? ''; if ($type === 'readonly') { $out .= '
'; $out .= ''; $out .= '
' . assoc_h($val ?: '—') . '
'; $out .= '
'; continue; } $out .= '
'; $out .= ''; if ($help) $out .= '' . assoc_h($help) . ''; if ($type === 'select' && !empty($f['options'])) { $out .= ''; } else { $out .= ''; } $out .= '
'; } } $out .= '
'; $out .= ' '; $out .= 'Back'; $out .= '
'; return $out; } function assoc_render_fields_form() { $def = assoc_load_fields(); $groups = $def['groups'] ?? []; $fields = $def['fields'] ?? []; $out = '
'; $out .= '

Manage Fields

'; $out .= '

Changes to labels and groups take effect immediately. Adding a field backfills all existing associations with the default value. Removing a field deletes its data from all associations — this cannot be undone.

'; $out .= '
'; $out .= assoc_csrf_token(); $out .= ''; $out .= ''; $out .= ''; foreach ($fields as $f) { $nick = $f['nickname']; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; } $out .= '
NicknameLabelTypeGroupHelp
' . assoc_h($nick) . '' . assoc_h($f['type'] ?? 'text') . ''; if (($f['type'] ?? '') !== 'readonly') { $out .= ''; } $out .= '
'; $out .= ''; $out .= '
'; foreach ($fields as $f) { if (($f['type'] ?? '') === 'readonly') continue; $nick = $f['nickname']; $out .= '
'; $out .= assoc_csrf_token(); $out .= ''; $out .= ''; $out .= '
'; } $out .= '
Add New Field
'; $out .= '
'; $out .= assoc_csrf_token(); $out .= ''; $out .= '
'; $out .= '
'; $out .= '
'; $out .= '
'; $out .= '
'; $out .= '
'; $out .= '
'; $out .= '
'; $out .= '
'; $out .= '
'; $out .= '
'; $out .= '
Group Order
'; $out .= '
'; $out .= assoc_csrf_token(); $out .= ''; $out .= '
'; $out .= '
'; $out .= ''; $out .= '
'; $out .= '
Back
'; $out .= '
'; return $out; }