OTC-Veranstaltungen eindeutig verknüpfen und Fehler sichtbar halten
This commit is contained in:
1 parent
184f50d034
commit
9fc85141e0
2 files changed
+19
-17
No files matched your search
@@ -357,7 +357,7 @@ function market_management_search_occurrences(PDO $pdo, array $input): array
|
|||||||
function market_management_list_active_occurrence_options(PDO $pdo): array
|
function market_management_list_active_occurrence_options(PDO $pdo): array
|
||||||
{
|
{
|
||||||
$stmt = $pdo->query(
|
$stmt = $pdo->query(
|
||||||
'SELECT o.id AS occurrence_id, m.name AS market_name, o.status,
|
'SELECT o.id AS occurrence_id, o.market_definition_id, m.name AS market_name, o.status,
|
||||||
d.id AS day_id, d.date
|
d.id AS day_id, d.date
|
||||||
FROM market_occurrence o
|
FROM market_occurrence o
|
||||||
INNER JOIN market_definition m ON m.id = o.market_definition_id
|
INNER JOIN market_definition m ON m.id = o.market_definition_id
|
||||||
|
|||||||
@@ -621,19 +621,20 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $otcM
|
|||||||
$otcMarketDayOptions = '';
|
$otcMarketDayOptions = '';
|
||||||
foreach ($otcMarketOptions as $option) {
|
foreach ($otcMarketOptions as $option) {
|
||||||
$occurrenceId = (int) ($option['occurrence_id'] ?? 0);
|
$occurrenceId = (int) ($option['occurrence_id'] ?? 0);
|
||||||
|
$marketDefinitionId = (int) ($option['market_definition_id'] ?? 0);
|
||||||
$dayId = (int) ($option['day_id'] ?? 0);
|
$dayId = (int) ($option['day_id'] ?? 0);
|
||||||
if ($occurrenceId <= 0 || $dayId <= 0) {
|
if ($occurrenceId <= 0 || $marketDefinitionId <= 0 || $dayId <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$marketName = (string) ($option['market_name'] ?? '');
|
$marketName = (string) ($option['market_name'] ?? '');
|
||||||
$otcMarketOccurrenceOptions[$occurrenceId] = $marketName;
|
$otcMarketOccurrenceOptions[$marketDefinitionId] = $marketName;
|
||||||
$day = (string) ($option['date'] ?? '');
|
$day = (string) ($option['date'] ?? '');
|
||||||
$dayLabel = $day === '' ? '' : (new DateTimeImmutable($day))->format('d.m.Y');
|
$dayLabel = $day === '' ? '' : (new DateTimeImmutable($day))->format('d.m.Y');
|
||||||
$otcMarketDayOptions .= '<option value="' . $dayId . '" data-market-occurrence-id="' . $occurrenceId . '">' . auth_escape_html($dayLabel) . '</option>';
|
$otcMarketDayOptions .= '<option value="' . $dayId . '" data-market-definition-id="' . $marketDefinitionId . '" data-market-occurrence-id="' . $occurrenceId . '">' . auth_escape_html($dayLabel) . '</option>';
|
||||||
}
|
}
|
||||||
$otcMarketOccurrenceOptionHtml = '<option value="">Veranstaltung auswählen</option>';
|
$otcMarketOccurrenceOptionHtml = '<option value="">Veranstaltung auswählen</option>';
|
||||||
foreach ($otcMarketOccurrenceOptions as $occurrenceId => $marketName) {
|
foreach ($otcMarketOccurrenceOptions as $marketDefinitionId => $marketName) {
|
||||||
$otcMarketOccurrenceOptionHtml .= '<option value="' . $occurrenceId . '">' . auth_escape_html($marketName) . '</option>';
|
$otcMarketOccurrenceOptionHtml .= '<option value="' . $marketDefinitionId . '">' . auth_escape_html($marketName) . '</option>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($otcProductRows === '') {
|
if ($otcProductRows === '') {
|
||||||
@@ -860,6 +861,7 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $otcM
|
|||||||
echo '<div class="sg-delete-confirmation-pattern__list" data-otc-confirmation-products aria-label="Produkte"></div>';
|
echo '<div class="sg-delete-confirmation-pattern__list" data-otc-confirmation-products aria-label="Produkte"></div>';
|
||||||
echo '<p class="sg-body sg-delete-confirmation-pattern__text"><strong>Gesamtzahl Flaschen: <span data-otc-confirmation-quantity>0</span></strong></p>';
|
echo '<p class="sg-body sg-delete-confirmation-pattern__text"><strong>Gesamtzahl Flaschen: <span data-otc-confirmation-quantity>0</span></strong></p>';
|
||||||
echo '<p class="sg-body sg-delete-confirmation-pattern__text"><strong>Gesamtbetrag: CHF <span data-otc-confirmation-total>0.00</span></strong></p>';
|
echo '<p class="sg-body sg-delete-confirmation-pattern__text"><strong>Gesamtbetrag: CHF <span data-otc-confirmation-total>0.00</span></strong></p>';
|
||||||
|
echo '<p class="sg-body sg-otc-order-form__status sg-otc-order-form__status--error hidden" data-otc-confirmation-error aria-live="polite"></p>';
|
||||||
echo '<div class="sg-delete-confirmation-pattern__actions">';
|
echo '<div class="sg-delete-confirmation-pattern__actions">';
|
||||||
echo '<button class="sg-interaction-element sg-button sg-button--active" type="button" data-otc-confirmation-cancel>Abbrechen</button>';
|
echo '<button class="sg-interaction-element sg-button sg-button--active" type="button" data-otc-confirmation-cancel>Abbrechen</button>';
|
||||||
echo '<button class="sg-interaction-element sg-button sg-button--process" type="button" data-otc-confirmation-submit>Verkaufen</button>';
|
echo '<button class="sg-interaction-element sg-button sg-button--process" type="button" data-otc-confirmation-submit>Verkaufen</button>';
|
||||||
@@ -1493,6 +1495,7 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $otcM
|
|||||||
echo " const confirmationQuantity = overlay.querySelector('[data-otc-confirmation-quantity]');";
|
echo " const confirmationQuantity = overlay.querySelector('[data-otc-confirmation-quantity]');";
|
||||||
echo " const confirmationTotal = overlay.querySelector('[data-otc-confirmation-total]');";
|
echo " const confirmationTotal = overlay.querySelector('[data-otc-confirmation-total]');";
|
||||||
echo " const confirmationSubmit = overlay.querySelector('[data-otc-confirmation-submit]');";
|
echo " const confirmationSubmit = overlay.querySelector('[data-otc-confirmation-submit]');";
|
||||||
|
echo " const confirmationError = overlay.querySelector('[data-otc-confirmation-error]');";
|
||||||
echo " let pendingOrderData = null;";
|
echo " let pendingOrderData = null;";
|
||||||
echo " const openTriggers = () => document.querySelectorAll('[data-otc-order-open]');";
|
echo " const openTriggers = () => document.querySelectorAll('[data-otc-order-open]');";
|
||||||
echo " const setTriggerState = (expanded) => {";
|
echo " const setTriggerState = (expanded) => {";
|
||||||
@@ -1500,6 +1503,7 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $otcM
|
|||||||
echo " };";
|
echo " };";
|
||||||
echo " const clearError = () => {";
|
echo " const clearError = () => {";
|
||||||
echo " if (errorEl) { errorEl.textContent = ''; errorEl.classList.add('hidden'); }";
|
echo " if (errorEl) { errorEl.textContent = ''; errorEl.classList.add('hidden'); }";
|
||||||
|
echo " if (confirmationError) { confirmationError.textContent = ''; confirmationError.classList.add('hidden'); }";
|
||||||
echo " };";
|
echo " };";
|
||||||
echo " const clearSuccess = () => {";
|
echo " const clearSuccess = () => {";
|
||||||
echo " if (successEl) { successEl.textContent = successDefaultText; successEl.classList.add('hidden'); }";
|
echo " if (successEl) { successEl.textContent = successDefaultText; successEl.classList.add('hidden'); }";
|
||||||
@@ -1538,7 +1542,7 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $otcM
|
|||||||
echo " const getFieldValue = (input) => (input ? input.value.trim() : '');";
|
echo " const getFieldValue = (input) => (input ? input.value.trim() : '');";
|
||||||
echo " const isMarketLinkEnabled = () => marketLinkToggle?.getAttribute('aria-checked') === 'true';";
|
echo " const isMarketLinkEnabled = () => marketLinkToggle?.getAttribute('aria-checked') === 'true';";
|
||||||
echo " const setDisabledSelectState = (select, disabled) => { if (!select) { return; } select.disabled = disabled; select.setAttribute('aria-disabled', String(disabled)); select.classList.toggle('sg-form-disabled', disabled); select.classList.toggle('sg-input-single-line--disabled', disabled); select.classList.toggle('sg-pulldown--disabled', disabled); select.classList.toggle('sg-form-inactive-selectable', !disabled); select.classList.toggle('sg-input-single-line--inactive-selectable', !disabled); };";
|
echo " const setDisabledSelectState = (select, disabled) => { if (!select) { return; } select.disabled = disabled; select.setAttribute('aria-disabled', String(disabled)); select.classList.toggle('sg-form-disabled', disabled); select.classList.toggle('sg-input-single-line--disabled', disabled); select.classList.toggle('sg-pulldown--disabled', disabled); select.classList.toggle('sg-form-inactive-selectable', !disabled); select.classList.toggle('sg-input-single-line--inactive-selectable', !disabled); };";
|
||||||
echo " const syncMarketDayOptions = () => { if (!marketOccurrenceInput || !marketDayInput) { return; } const occurrenceId = marketOccurrenceInput.value; Array.from(marketDayInput.options).forEach((option, index) => { if (index === 0) { option.hidden = false; option.disabled = false; return; } const matches = occurrenceId !== '' && option.dataset.marketOccurrenceId === occurrenceId; option.hidden = !matches; option.disabled = !matches; }); if (!occurrenceId || !Array.from(marketDayInput.options).some((option) => option.value === marketDayInput.value && !option.disabled)) { marketDayInput.value = ''; } setDisabledSelectState(marketDayInput, !isMarketLinkEnabled() || occurrenceId === ''); };";
|
echo " const syncMarketDayOptions = () => { if (!marketOccurrenceInput || !marketDayInput) { return; } const marketDefinitionId = marketOccurrenceInput.value; Array.from(marketDayInput.options).forEach((option, index) => { if (index === 0) { option.hidden = false; option.disabled = false; return; } const matches = marketDefinitionId !== '' && option.dataset.marketDefinitionId === marketDefinitionId; option.hidden = !matches; option.disabled = !matches; }); if (!marketDefinitionId || !Array.from(marketDayInput.options).some((option) => option.value === marketDayInput.value && !option.disabled)) { marketDayInput.value = ''; } setDisabledSelectState(marketDayInput, !isMarketLinkEnabled() || marketDefinitionId === ''); };";
|
||||||
echo " const syncMarketLinkState = () => { const enabled = isMarketLinkEnabled(); if (marketLinkEnabledInput) { marketLinkEnabledInput.value = enabled ? '1' : '0'; } setDisabledSelectState(marketOccurrenceInput, !enabled); if (!enabled && marketOccurrenceInput) { marketOccurrenceInput.value = ''; } syncMarketDayOptions(); };";
|
echo " const syncMarketLinkState = () => { const enabled = isMarketLinkEnabled(); if (marketLinkEnabledInput) { marketLinkEnabledInput.value = enabled ? '1' : '0'; } setDisabledSelectState(marketOccurrenceInput, !enabled); if (!enabled && marketOccurrenceInput) { marketOccurrenceInput.value = ''; } syncMarketDayOptions(); };";
|
||||||
echo " const updatePaymentAddButton = () => { addPaymentButton.disabled = paymentRows.querySelectorAll('[data-otc-payment-row]').length >= paymentOptionValues.length; };";
|
echo " const updatePaymentAddButton = () => { addPaymentButton.disabled = paymentRows.querySelectorAll('[data-otc-payment-row]').length >= paymentOptionValues.length; };";
|
||||||
echo " const updateFormState = () => {";
|
echo " const updateFormState = () => {";
|
||||||
@@ -1671,17 +1675,15 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $otcM
|
|||||||
echo " closeConfirmation();";
|
echo " closeConfirmation();";
|
||||||
echo " resetForm();";
|
echo " resetForm();";
|
||||||
echo " toggleOverlay(false);";
|
echo " toggleOverlay(false);";
|
||||||
echo " } else if (errorEl) {";
|
echo " } else {";
|
||||||
echo " errorEl.textContent = result.error || 'Unbekannter Fehler';";
|
echo " const message = result.error || 'Unbekannter Fehler';";
|
||||||
echo " errorEl.classList.remove('hidden');";
|
echo " if (errorEl) { errorEl.textContent = message; errorEl.classList.remove('hidden'); }";
|
||||||
echo " closeConfirmation();";
|
echo " if (confirmationError) { confirmationError.textContent = message; confirmationError.classList.remove('hidden'); }";
|
||||||
echo " }";
|
echo " }";
|
||||||
echo " } catch (error) {";
|
echo " } catch (error) {";
|
||||||
echo " if (errorEl) {";
|
echo " const message = 'Netzwerkfehler: ' + error.message;";
|
||||||
echo " errorEl.textContent = 'Netzwerkfehler: ' + error.message;";
|
echo " if (errorEl) { errorEl.textContent = message; errorEl.classList.remove('hidden'); }";
|
||||||
echo " errorEl.classList.remove('hidden');";
|
echo " if (confirmationError) { confirmationError.textContent = message; confirmationError.classList.remove('hidden'); }";
|
||||||
echo " }";
|
|
||||||
echo " closeConfirmation();";
|
|
||||||
echo " } finally {";
|
echo " } finally {";
|
||||||
echo " confirmationSubmit.innerHTML = originalBtnText;";
|
echo " confirmationSubmit.innerHTML = originalBtnText;";
|
||||||
echo " confirmationSubmit.disabled = false;";
|
echo " confirmationSubmit.disabled = false;";
|
||||||
@@ -1706,7 +1708,7 @@ function render_auth_home_page(array $user, array $otcProducts = [], array $otcM
|
|||||||
echo " zip: getFieldValue(zipInput),";
|
echo " zip: getFieldValue(zipInput),";
|
||||||
echo " city: getFieldValue(cityInput)";
|
echo " city: getFieldValue(cityInput)";
|
||||||
echo " },";
|
echo " },";
|
||||||
echo " marketOccurrenceId: isMarketLinkEnabled() ? getFieldValue(marketOccurrenceInput) : null,";
|
echo " marketOccurrenceId: isMarketLinkEnabled() ? (marketDayInput?.selectedOptions[0]?.dataset.marketOccurrenceId || null) : null,";
|
||||||
echo " marketOccurrenceDayId: isMarketLinkEnabled() ? getFieldValue(marketDayInput) : null";
|
echo " marketOccurrenceDayId: isMarketLinkEnabled() ? getFieldValue(marketDayInput) : null";
|
||||||
echo " };";
|
echo " };";
|
||||||
echo " openConfirmation(orderData);";
|
echo " openConfirmation(orderData);";
|
||||||
|
|||||||
Reference in new issue
Block a user