Commit 2b19960d authored by Fares's avatar Fares

feat(swimming): add discipline dropdown filter to player assignment page

The assignment page now shows a dropdown to select which sport's programs/groups
to display. Defaults to Swimming but allows switching to any active discipline.
Groups are filtered by the selected discipline and show their program names.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 60d769cf
...@@ -102,17 +102,25 @@ class SwimmingAssignmentController extends Controller ...@@ -102,17 +102,25 @@ class SwimmingAssignmentController extends Controller
return $this->redirect('/sa/swimming/register')->withError('يجب رفع الشهادة الطبية أولاً'); return $this->redirect('/sa/swimming/register')->withError('يجب رفع الشهادة الطبية أولاً');
} }
$selectedDiscipline = (int) ($request->get('discipline_id', 0) ?: $disciplineId);
$groups = $db->select(" $groups = $db->select("
SELECT g.id, g.name_ar, g.current_count, g.min_age, g.max_age, SELECT g.id, g.name_ar, g.current_count, g.min_age, g.max_age,
p.name_ar as program_name, p.max_capacity, p.monthly_fee_member, p.monthly_fee_nonmember, p.name_ar as program_name, p.max_capacity, p.monthly_fee_member, p.monthly_fee_nonmember,
p.age_from, p.age_to, p.age_from, p.age_to, p.id as program_id,
c.full_name_ar as coach_name c.full_name_ar as coach_name,
d.name_ar as discipline_name
FROM sa_groups g FROM sa_groups g
INNER JOIN sa_programs p ON p.id = g.program_id INNER JOIN sa_programs p ON p.id = g.program_id
INNER JOIN sa_disciplines d ON d.id = p.discipline_id
LEFT JOIN sa_coaches c ON c.id = g.coach_id LEFT JOIN sa_coaches c ON c.id = g.coach_id
WHERE p.discipline_id = ? AND g.status = 'active' AND g.is_archived = 0 WHERE p.discipline_id = ? AND g.status = 'active' AND g.is_archived = 0
ORDER BY p.name_ar ASC, g.name_ar ASC ORDER BY p.name_ar ASC, g.name_ar ASC
", [$disciplineId]); ", [$selectedDiscipline]);
$disciplines = $db->select(
"SELECT id, name_ar FROM sa_disciplines WHERE is_active = 1 AND is_archived = 0 ORDER BY name_ar"
);
$playerAge = null; $playerAge = null;
if (!empty($player['date_of_birth'])) { if (!empty($player['date_of_birth'])) {
...@@ -123,13 +131,15 @@ class SwimmingAssignmentController extends Controller ...@@ -123,13 +131,15 @@ class SwimmingAssignmentController extends Controller
} }
return $this->view('SportsActivity.Views.swimming.assign', [ return $this->view('SportsActivity.Views.swimming.assign', [
'players' => [], 'players' => [],
'player' => $player, 'player' => $player,
'playerId' => $playerId, 'playerId' => $playerId,
'playerAge' => $playerAge, 'playerAge' => $playerAge,
'groups' => $groups, 'groups' => $groups,
'mode' => 'assign', 'mode' => 'assign',
'disciplineId' => $disciplineId, 'disciplineId' => $disciplineId,
'selectedDiscipline' => $selectedDiscipline,
'disciplines' => $disciplines,
]); ]);
} }
......
...@@ -118,13 +118,34 @@ if ($done): ?> ...@@ -118,13 +118,34 @@ if ($done): ?>
</div> </div>
</div> </div>
<!-- Discipline Filter -->
<?php if (!empty($disciplines)): ?>
<div class="card" style="margin-bottom:16px;">
<div style="padding:14px 16px;display:flex;align-items:center;gap:12px;">
<label style="font-size:13px;font-weight:700;white-space:nowrap;"><i data-lucide="filter" style="width:14px;height:14px;vertical-align:middle;margin-left:4px;"></i>النشاط الرياضي:</label>
<select id="disciplineFilter" onchange="filterByDiscipline(this.value)" style="flex:1;padding:8px 12px;border:1px solid #D1D5DB;border-radius:8px;font-size:13px;">
<?php foreach ($disciplines as $d): ?>
<option value="<?= (int) $d['id'] ?>" <?= (int) $d['id'] === ($selectedDiscipline ?? 0) ? 'selected' : '' ?>><?= e($d['name_ar']) ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<script>
function filterByDiscipline(id) {
var url = new URL(window.location.href);
url.searchParams.set('discipline_id', id);
window.location.href = url.toString();
}
</script>
<?php endif; ?>
<!-- Groups Selection --> <!-- Groups Selection -->
<div class="card"> <div class="card">
<div style="padding:14px 16px;border-bottom:1px solid #E5E7EB;"> <div style="padding:14px 16px;border-bottom:1px solid #E5E7EB;">
<span style="font-weight:700;font-size:14px;"><i data-lucide="users" style="width:16px;height:16px;vertical-align:middle;margin-left:6px;"></i>اختر المجموعة</span> <span style="font-weight:700;font-size:14px;"><i data-lucide="users" style="width:16px;height:16px;vertical-align:middle;margin-left:6px;"></i>اختر المجموعة</span>
</div> </div>
<?php if (empty($groups)): ?> <?php if (empty($groups)): ?>
<div style="padding:30px;text-align:center;color:#9CA3AF;font-size:13px;">لا توجد مجموعات سباحة نشطة</div> <div style="padding:30px;text-align:center;color:#9CA3AF;font-size:13px;">لا توجد مجموعات نشطة لهذا النشاط الرياضي</div>
<?php else: ?> <?php else: ?>
<div style="padding:16px;"> <div style="padding:16px;">
<?php <?php
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment