Commit 8d1f5b04 authored by Mahmoud Aglan's avatar Mahmoud Aglan

feat: add "Open Registration" button for tournaments

Adds a new tournament workflow step between draft and start:
- draft → "فتح التسجيل" → registration (players can join)
- registration → "بدء البطولة" → in_progress

New route: POST /tournaments/{id}/open-registration
Sets status from 'draft' to 'registration' with audit log.
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 6eeebe52
......@@ -72,6 +72,7 @@ return [
'tournaments/{id}' => ['module' => 'tournaments', 'action' => 'show'],
'tournaments/{id}/edit' => ['module' => 'tournaments', 'action' => 'edit'],
'tournaments/{id}/update' => ['module' => 'tournaments', 'action' => 'update'],
'tournaments/{id}/open-registration' => ['module' => 'tournaments', 'action' => 'openRegistration'],
'tournaments/{id}/start' => ['module' => 'tournaments', 'action' => 'start'],
'tournaments/{id}/complete' => ['module' => 'tournaments', 'action' => 'complete'],
'tournaments/{id}/cancel' => ['module' => 'tournaments', 'action' => 'cancel'],
......
......@@ -335,6 +335,31 @@ class TournamentsController
Response::success('تم تحديث البطولة', '/tournaments/' . $id);
}
public function openRegistration(array $params, string $method): void
{
Auth::requireCsrf();
$id = $params['id'];
$tournament = $this->db->selectOne('el3ab_tournaments', ['id' => "eq.{$id}"]);
if (!$tournament) {
Response::error('البطولة غير موجودة', '/tournaments');
return;
}
if ($tournament['status'] !== 'draft') {
Response::error('يمكن فتح التسجيل فقط للبطولات في حالة المسودة', '/tournaments/' . $id);
return;
}
$this->db->update('el3ab_tournaments', ['id' => "eq.{$id}"], [
'status' => 'registration',
'updated_at' => date('c'),
]);
AuditLog::log('open_registration', 'tournament', $id, ['status' => 'draft'], ['status' => 'registration']);
Response::success('تم فتح التسجيل', '/tournaments/' . $id);
}
public function start(array $params, string $method): void
{
Auth::requireCsrf();
......
......@@ -53,6 +53,16 @@ $tabs['arbiter'] = 'أدوات الحكم';
</div>
</div>
<div class="flex gap-2">
<?php if ($tournament['status'] === 'draft'): ?>
<form method="POST" action="/tournaments/<?= $tournament['id'] ?>/open-registration" style="display:inline;">
<input type="hidden" name="_csrf" value="<?= Auth::csrfToken() ?>">
<button type="submit" class="btn btn-info" onclick="return confirm('فتح التسجيل للاعبين؟')">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M16 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="8.5" cy="7" r="4"/><line x1="20" y1="8" x2="20" y2="14"/><line x1="23" y1="11" x2="17" y2="11"/></svg>
فتح التسجيل
</button>
</form>
<?php endif; ?>
<?php if (in_array($tournament['status'], ['draft', 'registration'])): ?>
<form method="POST" action="/tournaments/<?= $tournament['id'] ?>/start" style="display:inline;">
<input type="hidden" name="_csrf" value="<?= Auth::csrfToken() ?>">
......
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