Compare commits
10 Commits
cd5a0f72de
...
a827275995
| Author | SHA1 | Date | |
|---|---|---|---|
| a827275995 | |||
|
|
49621a4423 | ||
|
|
67222fc6f9 | ||
|
|
eb7afe06ff | ||
|
|
b312cae473 | ||
|
|
e34ce64906 | ||
|
|
8fca38f6fe | ||
|
|
1c08324b24 | ||
|
|
a4719e9c58 | ||
|
|
c33eb3eaac |
@@ -131,7 +131,7 @@ function kc_teamer_page() {
|
|||||||
<td>".esc_html($tm->nachname)."</td>
|
<td>".esc_html($tm->nachname)."</td>
|
||||||
<td class='kc-actions'>
|
<td class='kc-actions'>
|
||||||
<a class='kc-btn edit' href='?page=kc_teamer&edit_teamer={$tm->id}'>Bearbeiten</a>
|
<a class='kc-btn edit' href='?page=kc_teamer&edit_teamer={$tm->id}'>Bearbeiten</a>
|
||||||
<a class='kc-btn del' href='?page=kc_teamer&delete_teamer={$tm->id}' onclick=\"return confirm('Wirklich loeschen?');\">Loeschen</a>
|
<a class='kc-btn del' href='?page=kc_teamer&delete_teamer={$tm->id}' onclick=\"return confirm('Wirklich löschen?');\">Löschen</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -274,10 +274,10 @@ function kc_teilnehmer_page() {
|
|||||||
// Gesamtanzahl Teilnehmer für diese Wahl berechnen
|
// Gesamtanzahl Teilnehmer für diese Wahl berechnen
|
||||||
$gesamt = 0;
|
$gesamt = 0;
|
||||||
foreach ($phasen as $tns) $gesamt += count($tns);
|
foreach ($phasen as $tns) $gesamt += count($tns);
|
||||||
echo '<details open style="margin:10px 0 18px 0;border:1px solid #eaeaea;border-radius:6px;padding:8px;">';
|
echo '<details style="margin:10px 0 18px 0;border:1px solid #eaeaea;border-radius:6px;padding:8px;">';
|
||||||
echo '<summary style="font-weight:700;cursor:pointer;">'. $wahl_disp . ' <span style="color:#555;font-weight:600;">(' . $gesamt . ' TN)</span></summary>';
|
echo '<summary style="font-weight:700;cursor:pointer;">'. $wahl_disp . ' <span style="color:#555;font-weight:600;">(' . $gesamt . ' TN)</span></summary>';
|
||||||
foreach ($phasen as $phase => $tns) {
|
foreach ($phasen as $phase => $tns) {
|
||||||
echo '<details open style="margin:10px 0 10px 0;border:1px solid #f0f0f0;border-radius:6px;padding:8px;">';
|
echo '<details style="margin:10px 0 10px 0;border:1px solid #f0f0f0;border-radius:6px;padding:8px;">';
|
||||||
echo '<summary style="font-weight:600;">Phase '.intval($phase).' <span style="color:#555;font-weight:600;">('.count($tns).' TN)</span></summary>';
|
echo '<summary style="font-weight:600;">Phase '.intval($phase).' <span style="color:#555;font-weight:600;">('.count($tns).' TN)</span></summary>';
|
||||||
echo '<table class="kc-admin-table" style="margin:8px 0;">';
|
echo '<table class="kc-admin-table" style="margin:8px 0;">';
|
||||||
echo '<thead><tr><th>Vorname</th><th>Nachname</th><th>Wahl</th><th>Phase</th><th>Wunsch 1</th><th>Wunsch 2</th><th>Wunsch 3</th><th>Aktion</th></tr></thead><tbody>';
|
echo '<thead><tr><th>Vorname</th><th>Nachname</th><th>Wahl</th><th>Phase</th><th>Wunsch 1</th><th>Wunsch 2</th><th>Wunsch 3</th><th>Aktion</th></tr></thead><tbody>';
|
||||||
@@ -299,7 +299,7 @@ function kc_teilnehmer_page() {
|
|||||||
<td>".$w3_disp."</td>
|
<td>".$w3_disp."</td>
|
||||||
<td class='kc-actions'>
|
<td class='kc-actions'>
|
||||||
<a class='kc-btn edit' href='?page=kc_teilnehmer&edit_teilnehmer={$tn->id}'>Bearbeiten</a>
|
<a class='kc-btn edit' href='?page=kc_teilnehmer&edit_teilnehmer={$tn->id}'>Bearbeiten</a>
|
||||||
<a class='kc-btn del' href='?page=kc_teilnehmer&delete_teilnehmer={$tn->id}' onclick=\"return confirm('Wirklich loeschen?');\">Loeschen</a>
|
<a class='kc-btn del' href='?page=kc_teilnehmer&delete_teilnehmer={$tn->id}' onclick=\"return confirm('Wirklich löschen?');\">Löschen</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ function kc_wahlen_page() {
|
|||||||
echo '<td>';
|
echo '<td>';
|
||||||
echo "<form method='post' style='display:inline'>";
|
echo "<form method='post' style='display:inline'>";
|
||||||
echo "<input type='hidden' name='wahl_id' value='".intval($wahl->id)."'>";
|
echo "<input type='hidden' name='wahl_id' value='".intval($wahl->id)."'>";
|
||||||
echo "<button name='kc_wahl_freigabe' value='".($wahl->freigegeben?"0":"1")."' class='kc-btn edit' type='submit' style='background:".($wahl->freigegeben?"#e12b2b":"#b6d333").";color:#fff;font-weight:bold;'>".($wahl->freigegeben?"Schlie<EFBFBD>en":"Freigeben (zum eintragen)")."</button>";
|
echo "<button name='kc_wahl_freigabe' value='".($wahl->freigegeben?"0":"1")."' class='kc-btn edit' type='submit' style='background:".($wahl->freigegeben?"#e12b2b":"#b6d333").";color:#fff;font-weight:bold;'>".($wahl->freigegeben?"Schließen":"Freigeben (zum eintragen)")."</button>";
|
||||||
echo "</form>";
|
echo "</form>";
|
||||||
echo '<span style="color:'.($wahl->freigegeben?"#4176be":"#d40000").';margin-left:6px;font-size:90%;font-weight:bold;">'.($wahl->freigegeben ? "freigegeben" : "geschlossen").'</span>';
|
echo '<span style="color:'.($wahl->freigegeben?"#4176be":"#d40000").';margin-left:6px;font-size:90%;font-weight:bold;">'.($wahl->freigegeben ? "freigegeben" : "geschlossen").'</span>';
|
||||||
echo '</td>';
|
echo '</td>';
|
||||||
@@ -363,7 +363,7 @@ function kc_wahlen_page() {
|
|||||||
echo '<a class="kc-btn" href="?page=kc_wahlen&show_zuteilung='.intval($wahl->id).'">Zuteilung anzeigen</a>';
|
echo '<a class="kc-btn" href="?page=kc_wahlen&show_zuteilung='.intval($wahl->id).'">Zuteilung anzeigen</a>';
|
||||||
$nonce = wp_create_nonce('kc_run_zuteilung_' . intval($wahl->id));
|
$nonce = wp_create_nonce('kc_run_zuteilung_' . intval($wahl->id));
|
||||||
echo '<a class="kc-btn" href="?page=kc_wahlen&run_zuteilung='.intval($wahl->id).'&_wpnonce='.$nonce.'" onclick="return confirm(\'Zuteilung wirklich starten? Dies überschreibt vorhandene Zuteilungen.\');">Zuteilung starten</a>';
|
echo '<a class="kc-btn" href="?page=kc_wahlen&run_zuteilung='.intval($wahl->id).'&_wpnonce='.$nonce.'" onclick="return confirm(\'Zuteilung wirklich starten? Dies überschreibt vorhandene Zuteilungen.\');">Zuteilung starten</a>';
|
||||||
echo '<a href="?page=kc_wahlen&delete_wahl='.intval($wahl->id).'" class="kc-btn del" onclick="return confirm(\'Wirklich loeschen?\');">Loeschen</a>';
|
echo '<a href="?page=kc_wahlen&delete_wahl='.intval($wahl->id).'" class="kc-btn del" onclick="return confirm(\'Wirklich löschen?\');">Löschen</a>';
|
||||||
echo '</td>';
|
echo '</td>';
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -542,7 +542,7 @@ function kc_workshops_page() {
|
|||||||
<td>". $wahl_str ."</td>
|
<td>". $wahl_str ."</td>
|
||||||
<td class='kc-actions'>
|
<td class='kc-actions'>
|
||||||
<a class='kc-btn edit' href='?page=kc_workshops&edit_workshop={$ws->id}'>Bearbeiten</a>
|
<a class='kc-btn edit' href='?page=kc_workshops&edit_workshop={$ws->id}'>Bearbeiten</a>
|
||||||
<a class='kc-btn del' href='?page=kc_workshops&delete_workshop={$ws->id}' onclick=\"return confirm('Wirklich loeschen?');\">Loeschen</a>
|
<a class='kc-btn del' href='?page=kc_workshops&delete_workshop={$ws->id}' onclick=\"return confirm('Wirklich löschen?');\">Löschen</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ function kc_force_zuteilung_page() {
|
|||||||
$prefix = $wpdb->prefix;
|
$prefix = $wpdb->prefix;
|
||||||
kc_admin_tabs('kc_force_zuteilung');
|
kc_admin_tabs('kc_force_zuteilung');
|
||||||
|
|
||||||
// Force-Zuteilung löschen
|
// Force-Zuteilung l<EFBFBD>schen
|
||||||
if (isset($_GET['delete_force'])) {
|
if (isset($_GET['delete_force'])) {
|
||||||
$fid = intval($_GET['delete_force']);
|
$fid = intval($_GET['delete_force']);
|
||||||
$wpdb->delete("{$prefix}kc_force_zuteilung", ['id' => $fid]);
|
$wpdb->delete("{$prefix}kc_force_zuteilung", ['id' => $fid]);
|
||||||
echo '<div class="notice notice-success">Force-Zuteilung gelöscht!</div>';
|
echo '<div class="notice notice-success">Force-Zuteilung gel<EFBFBD>scht!</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Force speichern (neu/ändern)
|
// Force speichern (neu/<EFBFBD>ndern)
|
||||||
if (isset($_POST['kc_force_save'])) {
|
if (isset($_POST['kc_force_save'])) {
|
||||||
$data = [
|
$data = [
|
||||||
'teilnehmer_id' => intval($_POST['teilnehmer_id']),
|
'teilnehmer_id' => intval($_POST['teilnehmer_id']),
|
||||||
@@ -29,69 +29,143 @@ function kc_force_zuteilung_page() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Listen für Dropdowns
|
// Listen f<EFBFBD>r Dropdowns
|
||||||
$teilnehmer_liste = $wpdb->get_results("SELECT * FROM {$prefix}kc_teilnehmer ORDER BY nachname, vorname");
|
$teilnehmer_liste = $wpdb->get_results("SELECT * FROM {$prefix}kc_teilnehmer ORDER BY nachname, vorname");
|
||||||
$workshop_liste = $wpdb->get_results("SELECT * FROM {$prefix}kc_workshops ORDER BY name");
|
$workshop_liste = $wpdb->get_results("SELECT * FROM {$prefix}kc_workshops ORDER BY name");
|
||||||
$wahlen = $wpdb->get_results("SELECT id, name FROM {$prefix}kc_wahlen WHERE deleted=0 ORDER BY name");
|
$wahlen = $wpdb->get_results("SELECT id, name, COALESCE(anzahl_einheiten,1) AS anzahl_einheiten FROM {$prefix}kc_wahlen WHERE deleted=0 ORDER BY name");
|
||||||
|
|
||||||
// Bearbeiten
|
// Bearbeiten
|
||||||
if (isset($_GET['edit_force'])) {
|
if (isset($_GET['edit_force'])) {
|
||||||
$fid = intval($_GET['edit_force']);
|
$fid = intval($_GET['edit_force']);
|
||||||
$fz = $wpdb->get_row("SELECT * FROM {$prefix}kc_force_zuteilung WHERE id=$fid");
|
$fz = $wpdb->get_row("SELECT * FROM {$prefix}kc_force_zuteilung WHERE id=$fid");
|
||||||
echo '<div class="kc-admin-table-wrap">';
|
echo '<div class="kc-admin-table-wrap">';
|
||||||
echo '<h2>Force-Zuteilung bearbeiten</h2>
|
echo '<h2>Force-Zuteilung bearbeiten</h2>';
|
||||||
<form method="post">
|
echo '<div class="kc-form-container" style="max-width:880px;padding:18px 20px;border-radius:10px;background:#fff;border:1px solid #eef3f2;">';
|
||||||
<input type="hidden" name="fid" value="'.intval($fz->id).'">
|
echo '<form method="post">';
|
||||||
<div class="kc-form-row">
|
echo '<input type="hidden" name="fid" value="'.intval($fz->id).'">';
|
||||||
<label>Teilnehmer <span class="kc-required">*</span></label>
|
echo '<div style="display:grid;grid-template-columns:1fr 1fr;gap:12px;align-items:start">';
|
||||||
<select name="teilnehmer_id" id="kc-force-teilnehmer-dropdown" style="width:100%">
|
|
||||||
<option value="">Teilnehmer auswählen…</option>';
|
// Teilnehmer
|
||||||
|
echo '<div class="kc-form-row" style="min-width:0">';
|
||||||
|
echo '<label>Teilnehmer <span class="kc-required">*</span></label>';
|
||||||
|
echo '<select name="teilnehmer_id" id="kc-force-teilnehmer-dropdown" style="width:100%">';
|
||||||
|
echo '<option value="">Teilnehmer auswählen…</option>';
|
||||||
foreach($teilnehmer_liste as $t) {
|
foreach($teilnehmer_liste as $t) {
|
||||||
echo '<option value="'.esc_attr($t->id).'"'.($fz->teilnehmer_id==$t->id?' selected':'').'>'
|
echo '<option value="'.esc_attr($t->id).'"'.($fz->teilnehmer_id==$t->id?' selected':'').'>'
|
||||||
.esc_html($t->vorname.' '.$t->nachname.' (ID: '.$t->id.')')
|
.esc_html($t->vorname.' '.$t->nachname.' (ID: '.$t->id.')')
|
||||||
.'</option>';
|
.'</option>';
|
||||||
}
|
}
|
||||||
echo ' </select>
|
echo '</select>';
|
||||||
</div>
|
echo '</div>';
|
||||||
<div class="kc-form-row">
|
|
||||||
<label>Wahl <span class="kc-required">*</span></label>
|
// Wahl
|
||||||
<select name="wahl_id" id="kc-force-wahl-dropdown" style="width:100%">
|
echo '<div class="kc-form-row" style="min-width:0">';
|
||||||
<option value="">Wahl auswählen…</option>';
|
echo '<label>Wahl <span class="kc-required">*</span></label>';
|
||||||
|
echo '<select name="wahl_id" id="kc-force-wahl-dropdown" style="width:100%">';
|
||||||
|
echo '<option value="">Wahl auswählen…</option>';
|
||||||
foreach($wahlen as $w) {
|
foreach($wahlen as $w) {
|
||||||
echo '<option value="'.intval($w->id).'"'.($fz->wahl_id==$w->id?' selected':'').'>'
|
echo '<option value="'.intval($w->id).'" data-einheiten="'.intval($w->anzahl_einheiten).'"'.($fz->wahl_id==$w->id?' selected':'').'>'.esc_html($w->name.' (ID '.$w->id.')').'</option>';
|
||||||
.esc_html($w->name.' (ID '.$w->id.')').'</option>';
|
|
||||||
}
|
}
|
||||||
echo ' </select>
|
echo '</select>';
|
||||||
</div>
|
echo '</div>';
|
||||||
<div class="kc-form-row">
|
|
||||||
<label>Phase</label>
|
// Phase (select so JS can populate based on Wahl)
|
||||||
<input type="number" name="phase" value="'.intval($fz->phase).'" style="width:100%">
|
echo '<div class="kc-form-row" style="min-width:0">';
|
||||||
</div>
|
echo '<label>Phase</label>';
|
||||||
<div class="kc-form-row">
|
echo '<select name="phase" style="width:100%;padding:8px;border-radius:6px;border:1px solid #ddd">';
|
||||||
<label>Workshop <span class="kc-required">*</span></label>
|
echo '<option value="'.intval($fz->phase).'">'.intval($fz->phase).'</option>';
|
||||||
<select name="workshop_id" id="kc-force-workshop-dropdown" style="width:100%">
|
echo '</select>';
|
||||||
<option value="">Workshop auswählen…</option>';
|
echo '</div>';
|
||||||
|
|
||||||
|
// Workshop
|
||||||
|
echo '<div class="kc-form-row" style="min-width:0">';
|
||||||
|
echo '<label>Workshop <span class="kc-required">*</span></label>';
|
||||||
|
echo '<select name="workshop_id" id="kc-force-workshop-dropdown" style="width:100%">';
|
||||||
|
echo '<option value="">Workshop auswählen…</option>';
|
||||||
foreach($workshop_liste as $ws) {
|
foreach($workshop_liste as $ws) {
|
||||||
echo '<option value="'.esc_attr($ws->id).'"'.($fz->workshop_id==$ws->id?' selected':'').'>'
|
echo '<option value="'.esc_attr($ws->id).'"'.($fz->workshop_id==$ws->id?' selected':'').'>'
|
||||||
.esc_html($ws->name)
|
.esc_html($ws->name)
|
||||||
.'</option>';
|
.'</option>';
|
||||||
}
|
}
|
||||||
echo ' </select>
|
echo '</select>';
|
||||||
</div>
|
echo '</div>';
|
||||||
<div class="kc-form-row">
|
|
||||||
<label>Kommentar</label>
|
// Kommentar (full width)
|
||||||
<input type="text" name="kommentar" value="'.esc_attr($fz->kommentar).'" style="width:100%">
|
echo '<div style="grid-column:1/ -1">';
|
||||||
</div>
|
echo '<div class="kc-form-row">';
|
||||||
<button name="kc_force_save" class="kc-btn">Speichern</button>
|
echo '<label>Kommentar</label>';
|
||||||
<a href="?page=kc_force_zuteilung" class="kc-btn del" style="margin-left:24px;">Abbrechen</a>
|
echo '<input type="text" name="kommentar" value="'.esc_attr($fz->kommentar).'" style="width:100%;padding:8px;border-radius:6px;border:1px solid #ddd">';
|
||||||
</form>
|
echo '</div>';
|
||||||
<script>
|
echo '</div>';
|
||||||
jQuery(function($){
|
|
||||||
$("#kc-force-teilnehmer-dropdown").select2({placeholder:"Teilnehmer auswählen…",allowClear:true});
|
echo '</div>'; // grid
|
||||||
$("#kc-force-wahl-dropdown").select2({placeholder:"Wahl auswählen…",allowClear:true});
|
|
||||||
$("#kc-force-workshop-dropdown").select2({placeholder:"Workshop auswählen…",allowClear:true});
|
echo '<div style="margin-top:12px;display:flex;gap:10px;justify-content:flex-start">';
|
||||||
|
echo '<button name="kc_force_save" class="kc-btn" style="padding:8px 16px;">Speichern</button>';
|
||||||
|
echo '<a href="?page=kc_force_zuteilung" class="kc-btn del" style="padding:8px 16px;">Abbrechen</a>';
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
echo '</form>';
|
||||||
|
echo '</div>';
|
||||||
|
// Prepare JS mapping of wahl_id -> number of phases
|
||||||
|
$wahl_phases = [];
|
||||||
|
foreach ($wahlen as $w) $wahl_phases[intval($w->id)] = intval($w->anzahl_einheiten);
|
||||||
|
|
||||||
|
echo '<script>var kcWahlPhases = ' . wp_json_encode($wahl_phases) . ';</script>';
|
||||||
|
echo <<<'JS'
|
||||||
|
<script>
|
||||||
|
jQuery(function($){
|
||||||
|
$("#kc-force-teilnehmer-dropdown").select2({placeholder:"Teilnehmer auswählen…",allowClear:true});
|
||||||
|
$("#kc-force-wahl-dropdown").select2({placeholder:"Wahl auswählen…",allowClear:true});
|
||||||
|
$("#kc-force-workshop-dropdown").select2({placeholder:"Workshop auswählen…",allowClear:true});
|
||||||
|
|
||||||
|
function refreshPhaseSelect($wahlSelect, $phaseSelect, current) {
|
||||||
|
// prefer data attribute on the selected option; fall back to kcWahlPhases mapping
|
||||||
|
var selOpt = $wahlSelect.find('option:selected');
|
||||||
|
var max = parseInt(selOpt.data('einheiten') || kcWahlPhases[parseInt($wahlSelect.val(),10)] || 1, 10);
|
||||||
|
$phaseSelect.empty();
|
||||||
|
for(var i=1;i<=max;i++){
|
||||||
|
var opt = $("<option>").val(i).text(i + (i===1? " (Phase)":" (Phase)"));
|
||||||
|
$phaseSelect.append(opt);
|
||||||
|
}
|
||||||
|
if (current) {
|
||||||
|
$phaseSelect.val(current);
|
||||||
|
}
|
||||||
|
$phaseSelect.prop("disabled", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bind change for all existing wahl selects on the page
|
||||||
|
$(document).on("change", "#kc-force-wahl-dropdown", function(){
|
||||||
|
var $w = $(this);
|
||||||
|
var $phase = $w.closest("form").find("[name='phase']");
|
||||||
|
// try immediate refresh; if no data found, fallback to AJAX
|
||||||
|
var sel = $w.find('option:selected');
|
||||||
|
var einheiten = sel.data('einheiten') || kcWahlPhases[parseInt($w.val(),10)];
|
||||||
|
if (einheiten) {
|
||||||
|
refreshPhaseSelect($w, $phase);
|
||||||
|
} else {
|
||||||
|
// AJAX fallback to ask server for anzahl_einheiten
|
||||||
|
$.get(ajaxurl, {action: 'kc_get_wahl', id: $w.val()}).done(function(r){
|
||||||
|
if (r && r.success && r.data && r.data.anzahl_einheiten) {
|
||||||
|
// set data attribute so future reads find it
|
||||||
|
sel.data('einheiten', parseInt(r.data.anzahl_einheiten,10));
|
||||||
|
}
|
||||||
|
refreshPhaseSelect($w, $phase);
|
||||||
|
}).fail(function(){ refreshPhaseSelect($w, $phase); });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>';
|
|
||||||
|
// Initialize existing phase selects based on their selected wahl
|
||||||
|
$("[name='phase']").each(function(){
|
||||||
|
var $phase = $(this);
|
||||||
|
var $form = $phase.closest("form");
|
||||||
|
var $wahl = $form.find("#kc-force-wahl-dropdown");
|
||||||
|
var current = $phase.val();
|
||||||
|
refreshPhaseSelect($wahl, $phase, current);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
JS;
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -99,63 +173,82 @@ function kc_force_zuteilung_page() {
|
|||||||
// Neu anlegen
|
// Neu anlegen
|
||||||
if (isset($_GET['new'])) {
|
if (isset($_GET['new'])) {
|
||||||
echo '<div class="kc-admin-table-wrap">';
|
echo '<div class="kc-admin-table-wrap">';
|
||||||
echo '<h2>Neue Force-Zuteilung</h2>
|
echo '<h2>Neue Force-Zuteilung</h2>';
|
||||||
<form method="post">
|
echo '<div class="kc-form-container" style="max-width:880px;padding:18px 20px;border-radius:10px;background:#fff;border:1px solid #eef3f2;">';
|
||||||
<div class="kc-form-row">
|
echo '<form method="post">';
|
||||||
<label>Teilnehmer <span class="kc-required">*</span></label>
|
|
||||||
<select name="teilnehmer_id" id="kc-force-teilnehmer-dropdown" style="width:100%">
|
echo '<div style="display:grid;grid-template-columns:1fr 1fr;gap:12px;align-items:start">';
|
||||||
<option value="">Teilnehmer auswählen…</option>';
|
|
||||||
|
// Teilnehmer
|
||||||
|
echo '<div class="kc-form-row" style="min-width:0">';
|
||||||
|
echo '<label>Teilnehmer <span class="kc-required">*</span></label>';
|
||||||
|
echo '<select name="teilnehmer_id" id="kc-force-teilnehmer-dropdown" style="width:100%">';
|
||||||
|
echo '<option value="">Teilnehmer auswählen…</option>';
|
||||||
foreach($teilnehmer_liste as $t) {
|
foreach($teilnehmer_liste as $t) {
|
||||||
echo '<option value="'.esc_attr($t->id).'">'
|
echo '<option value="'.esc_attr($t->id).'">'.esc_html($t->vorname.' '.$t->nachname.' (ID: '.$t->id.')').'</option>';
|
||||||
.esc_html($t->vorname.' '.$t->nachname.' (ID: '.$t->id.')')
|
|
||||||
.'</option>';
|
|
||||||
}
|
}
|
||||||
echo ' </select>
|
echo '</select>';
|
||||||
</div>
|
echo '</div>';
|
||||||
<div class="kc-form-row">
|
|
||||||
<label>Wahl <span class="kc-required">*</span></label>
|
// Wahl
|
||||||
<select name="wahl_id" id="kc-force-wahl-dropdown" style="width:100%">
|
echo '<div class="kc-form-row" style="min-width:0">';
|
||||||
<option value="">Wahl auswählen…</option>';
|
echo '<label>Wahl <span class="kc-required">*</span></label>';
|
||||||
|
echo '<select name="wahl_id" id="kc-force-wahl-dropdown" style="width:100%">';
|
||||||
|
echo '<option value="">Wahl auswählen…</option>';
|
||||||
foreach($wahlen as $w) {
|
foreach($wahlen as $w) {
|
||||||
echo '<option value="'.intval($w->id).'">'
|
echo '<option value="'.intval($w->id).'" data-einheiten="'.intval($w->anzahl_einheiten).'">'.esc_html($w->name.' (ID '.$w->id.')').'</option>';
|
||||||
.esc_html($w->name.' (ID '.$w->id.')').'</option>';
|
|
||||||
}
|
}
|
||||||
echo ' </select>
|
echo '</select>';
|
||||||
</div>
|
echo '</div>';
|
||||||
<div class="kc-form-row">
|
|
||||||
<label>Phase</label>
|
// Phase (select so JS can populate based on Wahl)
|
||||||
<input type="number" name="phase" value="1" style="width:100%">
|
echo '<div class="kc-form-row" style="min-width:0">';
|
||||||
</div>
|
echo '<label>Phase</label>';
|
||||||
<div class="kc-form-row">
|
echo '<select name="phase" style="width:100%;padding:8px;border-radius:6px;border:1px solid #ddd">';
|
||||||
<label>Workshop <span class="kc-required">*</span></label>
|
echo '<option value="1">1</option>';
|
||||||
<select name="workshop_id" id="kc-force-workshop-dropdown" style="width:100%">
|
echo '</select>';
|
||||||
<option value="">Workshop auswählen…</option>';
|
echo '</div>';
|
||||||
|
|
||||||
|
// Workshop
|
||||||
|
echo '<div class="kc-form-row" style="min-width:0">';
|
||||||
|
echo '<label>Workshop <span class="kc-required">*</span></label>';
|
||||||
|
echo '<select name="workshop_id" id="kc-force-workshop-dropdown" style="width:100%">';
|
||||||
|
echo '<option value="">Workshop auswählen…</option>';
|
||||||
foreach($workshop_liste as $ws) {
|
foreach($workshop_liste as $ws) {
|
||||||
echo '<option value="'.esc_attr($ws->id).'">'
|
echo '<option value="'.esc_attr($ws->id).'">'.esc_html($ws->name).'</option>';
|
||||||
.esc_html($ws->name)
|
|
||||||
.'</option>';
|
|
||||||
}
|
}
|
||||||
echo ' </select>
|
echo '</select>';
|
||||||
</div>
|
echo '</div>';
|
||||||
<div class="kc-form-row">
|
|
||||||
<label>Kommentar</label>
|
// Kommentar full width
|
||||||
<input type="text" name="kommentar" style="width:100%">
|
echo '<div style="grid-column:1/ -1">';
|
||||||
</div>
|
echo '<div class="kc-form-row">';
|
||||||
<button name="kc_force_save" class="kc-btn">Speichern</button>
|
echo '<label>Kommentar</label>';
|
||||||
<a href="?page=kc_force_zuteilung" class="kc-btn del" style="margin-left:24px;">Abbrechen</a>
|
echo '<input type="text" name="kommentar" style="width:100%;padding:8px;border-radius:6px;border:1px solid #ddd">';
|
||||||
</form>
|
echo '</div>';
|
||||||
<script>
|
echo '</div>';
|
||||||
|
|
||||||
|
echo '</div>'; // grid
|
||||||
|
|
||||||
|
echo '<div style="margin-top:12px;display:flex;gap:10px;justify-content:flex-start">';
|
||||||
|
echo '<button name="kc_force_save" class="kc-btn" style="padding:8px 16px;">Speichern</button>';
|
||||||
|
echo '<a href="?page=kc_force_zuteilung" class="kc-btn del" style="padding:8px 16px;">Abbrechen</a>';
|
||||||
|
echo '</div>';
|
||||||
|
|
||||||
|
echo '</form>';
|
||||||
|
echo '</div>';
|
||||||
|
echo '<script>
|
||||||
jQuery(function($){
|
jQuery(function($){
|
||||||
$("#kc-force-teilnehmer-dropdown").select2({placeholder:"Teilnehmer auswählen…",allowClear:true});
|
$("#kc-force-teilnehmer-dropdown").select2({placeholder:"Teilnehmer auswählen…",allowClear:true});
|
||||||
$("#kc-force-wahl-dropdown").select2({placeholder:"Wahl auswählen…",allowClear:true});
|
$("#kc-force-wahl-dropdown").select2({placeholder:"Wahl auswählen…",allowClear:true});
|
||||||
$("#kc-force-workshop-dropdown").select2({placeholder:"Workshop auswählen…",allowClear:true});
|
$("#kc-force-workshop-dropdown").select2({placeholder:"Workshop auswählen…",allowClear:true});
|
||||||
});
|
});
|
||||||
</script>';
|
</script>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Übersicht
|
// <EFBFBD>bersicht
|
||||||
echo '<div class="kc-admin-table-wrap">';
|
echo '<div class="kc-admin-table-wrap">';
|
||||||
echo '<h2 style="margin-top:0;">Alle Force-Zuteilungen</h2>';
|
echo '<h2 style="margin-top:0;">Alle Force-Zuteilungen</h2>';
|
||||||
echo '<a class="kc-btn" style="float:right;margin-bottom:12px;" href="?page=kc_force_zuteilung&new=1">+ Neue Force-Zuteilung</a>';
|
echo '<a class="kc-btn" style="float:right;margin-bottom:12px;" href="?page=kc_force_zuteilung&new=1">+ Neue Force-Zuteilung</a>';
|
||||||
@@ -176,7 +269,7 @@ function kc_force_zuteilung_page() {
|
|||||||
<td>".esc_html($f->kommentar)."</td>
|
<td>".esc_html($f->kommentar)."</td>
|
||||||
<td class='kc-actions'>
|
<td class='kc-actions'>
|
||||||
<a class='kc-btn edit' href='?page=kc_force_zuteilung&edit_force={$f->id}'>Bearbeiten</a>
|
<a class='kc-btn edit' href='?page=kc_force_zuteilung&edit_force={$f->id}'>Bearbeiten</a>
|
||||||
<a class='kc-btn del' href='?page=kc_force_zuteilung&delete_force={$f->id}' onclick=\"return confirm('Wirklich loeschen?');\">Loeschen</a>
|
<a class='kc-btn del' href='?page=kc_force_zuteilung&delete_force={$f->id}' onclick=\"return confirm('Wirklich löschen?');\">löschen</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
// AJAX endpoint to return wahl details (anzahl_einheiten)
|
||||||
|
add_action('wp_ajax_kc_get_wahl', function(){
|
||||||
|
global $wpdb;
|
||||||
|
$id = isset($_GET['id']) ? intval($_GET['id']) : 0;
|
||||||
|
if (!$id) {
|
||||||
|
wp_send_json_error('missing id');
|
||||||
|
}
|
||||||
|
$row = $wpdb->get_row($wpdb->prepare("SELECT id, COALESCE(anzahl_einheiten,1) as anzahl_einheiten FROM {$wpdb->prefix}kc_wahlen WHERE id=%d", $id));
|
||||||
|
if (!$row) wp_send_json_error('not found');
|
||||||
|
wp_send_json_success(['id'=>intval($row->id),'anzahl_einheiten'=>intval($row->anzahl_einheiten)]);
|
||||||
|
});
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plugin Name: Workshop-Wahlen
|
* Plugin Name: Workshop-Wahlen
|
||||||
* Description: Workshop-Wahl-System für Konfi-Castle.com
|
* Description: Workshop-Wahl-System für Konfi-Castle.com
|
||||||
|
|||||||
Reference in New Issue
Block a user