Commit 201fc0a9 authored by Mahmoud Aglan's avatar Mahmoud Aglan

dtjdyrjkdyrk

cfgmfghmhdjkd
parent dbd4146a
...@@ -115,7 +115,7 @@ class RegistrationWizardController extends Controller ...@@ -115,7 +115,7 @@ class RegistrationWizardController extends Controller
$registration = $db->selectOne( $registration = $db->selectOne(
"SELECT r.*, p.full_name_ar, p.full_name_en, p.national_id as player_nid, "SELECT r.*, p.full_name_ar, p.full_name_en, p.national_id as player_nid,
p.date_of_birth, p.gender, p.phone, p.photo_path, p.player_type as p_type, p.date_of_birth, p.gender, p.phone, p.photo_path, p.player_type as p_type,
p.guardian_name, p.guardian_phone p.guardian_name, p.guardian_phone, p.guardian_national_id, p.guardian_relationship
FROM sa_registrations r FROM sa_registrations r
INNER JOIN sa_players p ON p.id = r.player_id INNER JOIN sa_players p ON p.id = r.player_id
WHERE r.id = ?", WHERE r.id = ?",
...@@ -176,6 +176,13 @@ class RegistrationWizardController extends Controller ...@@ -176,6 +176,13 @@ class RegistrationWizardController extends Controller
return $this->json($result); return $this->json($result);
} }
public function submitFormPayment(Request $request, string $id): Response
{
$registrationId = (int) $id;
$result = RegistrationWizardService::submitFormPayment($registrationId);
return $this->json($result);
}
public function selectActivity(Request $request, string $id): Response public function selectActivity(Request $request, string $id): Response
{ {
$registrationId = (int) $id; $registrationId = (int) $id;
...@@ -356,22 +363,28 @@ class RegistrationWizardController extends Controller ...@@ -356,22 +363,28 @@ class RegistrationWizardController extends Controller
private function determineStep(array $registration): int private function determineStep(array $registration): int
{ {
if ($registration['status'] === 'completed') { // Step 1: Pay form fee (استمارة اشتراك)
return 5; // Step 2: Photo capture
} // Step 3: Select activity/group
if ($registration['payment_status'] === 'paid') { // Step 4: Pay subscription
// Step 5: Complete (print/card)
if ($registration['status'] === 'completed' || $registration['payment_status'] === 'paid') {
return 5; return 5;
} }
if ($registration['status'] === 'pending_payment') { if ($registration['status'] === 'pending_payment') {
return 4; return 4;
} }
if (!empty($registration['group_id'])) { if (!empty($registration['group_id'])) {
return 3; return 4;
} }
if ((int) $registration['photo_captured'] === 1) { if ((int) $registration['photo_captured'] === 1) {
return 3; return 3;
} }
return 2; $formPaid = ($registration['form_payment_status'] ?? 'unpaid') === 'paid';
if ($formPaid) {
return 2;
}
return 1;
} }
private function base64ToTempFile(string $base64): ?array private function base64ToTempFile(string $base64): ?array
......
...@@ -193,6 +193,7 @@ return [ ...@@ -193,6 +193,7 @@ return [
['GET', '/sa/registration', 'SportsActivity\Controllers\RegistrationWizardController@index', ['auth'], 'sa.registration.manage'], ['GET', '/sa/registration', 'SportsActivity\Controllers\RegistrationWizardController@index', ['auth'], 'sa.registration.manage'],
['POST', '/sa/registration/lookup', 'SportsActivity\Controllers\RegistrationWizardController@lookupPlayer', ['auth', 'csrf'], 'sa.registration.manage'], ['POST', '/sa/registration/lookup', 'SportsActivity\Controllers\RegistrationWizardController@lookupPlayer', ['auth', 'csrf'], 'sa.registration.manage'],
['GET', '/sa/registration/{id:\d+}', 'SportsActivity\Controllers\RegistrationWizardController@wizardStep', ['auth'], 'sa.registration.manage'], ['GET', '/sa/registration/{id:\d+}', 'SportsActivity\Controllers\RegistrationWizardController@wizardStep', ['auth'], 'sa.registration.manage'],
['POST', '/sa/registration/{id:\d+}/pay-form', 'SportsActivity\Controllers\RegistrationWizardController@submitFormPayment', ['auth', 'csrf'], 'sa.registration.manage'],
['POST', '/sa/registration/{id:\d+}/photo', 'SportsActivity\Controllers\RegistrationWizardController@uploadPhoto', ['auth', 'csrf'], 'sa.registration.manage'], ['POST', '/sa/registration/{id:\d+}/photo', 'SportsActivity\Controllers\RegistrationWizardController@uploadPhoto', ['auth', 'csrf'], 'sa.registration.manage'],
['POST', '/sa/registration/{id:\d+}/activity', 'SportsActivity\Controllers\RegistrationWizardController@selectActivity', ['auth', 'csrf'], 'sa.registration.manage'], ['POST', '/sa/registration/{id:\d+}/activity', 'SportsActivity\Controllers\RegistrationWizardController@selectActivity', ['auth', 'csrf'], 'sa.registration.manage'],
['POST', '/sa/registration/{id:\d+}/pay', 'SportsActivity\Controllers\RegistrationWizardController@submitPayment', ['auth', 'csrf'], 'sa.registration.manage'], ['POST', '/sa/registration/{id:\d+}/pay', 'SportsActivity\Controllers\RegistrationWizardController@submitPayment', ['auth', 'csrf'], 'sa.registration.manage'],
......
...@@ -248,10 +248,11 @@ final class RegistrationWizardService ...@@ -248,10 +248,11 @@ final class RegistrationWizardService
+ $subscriptionAfterDiscount; + $subscriptionAfterDiscount;
$db->update('sa_registrations', [ $db->update('sa_registrations', [
'group_id' => $groupId, 'group_id' => $groupId,
'subscription_amount' => $subscriptionAfterDiscount, 'subscription_amount' => $subscriptionAfterDiscount,
'total_fees' => $totalFees, 'subscription_months' => $months,
'updated_at' => date('Y-m-d H:i:s'), 'total_fees' => $totalFees,
'updated_at' => date('Y-m-d H:i:s'),
], 'id = ?', [$registrationId]); ], 'id = ?', [$registrationId]);
return [ return [
...@@ -289,6 +290,60 @@ final class RegistrationWizardService ...@@ -289,6 +290,60 @@ final class RegistrationWizardService
]; ];
} }
public static function submitFormPayment(int $registrationId): array
{
$db = App::getInstance()->db();
$registration = $db->selectOne(
"SELECT r.*, p.full_name_ar, p.member_id
FROM sa_registrations r
INNER JOIN sa_players p ON p.id = r.player_id
WHERE r.id = ? AND r.status = 'in_progress'",
[$registrationId]
);
if (!$registration) {
return ['success' => false, 'error' => 'التسجيل غير موجود أو مكتمل'];
}
if ($registration['form_payment_status'] === 'paid') {
return ['success' => true, 'already_paid' => true];
}
$formFee = (float) $registration['registration_fee'];
if ($formFee <= 0) {
return ['success' => false, 'error' => 'رسوم الاستمارة غير محددة'];
}
$memberId = (int) ($registration['member_id'] ?? 0);
$description = 'استمارة اشتراك نشاط رياضي — ' . ($registration['full_name_ar'] ?? '');
$result = PaymentRequestService::createRequest([
'member_id' => $memberId,
'payment_type' => 'sa_form_fee',
'amount' => (string) $formFee,
'description_ar' => $description,
'related_entity_type' => 'sa_registration_form',
'related_entity_id' => $registrationId,
]);
if (!$result['success']) {
return $result;
}
$db->update('sa_registrations', [
'form_payment_request_id' => (int) $result['request_id'],
'form_payment_status' => 'pending',
'updated_at' => date('Y-m-d H:i:s'),
], 'id = ?', [$registrationId]);
return [
'success' => true,
'request_id' => $result['request_id'],
'request_number' => $result['request_number'],
'amount' => $formFee,
];
}
public static function submitToPaymentQueue(int $registrationId): array public static function submitToPaymentQueue(int $registrationId): array
{ {
$db = App::getInstance()->db(); $db = App::getInstance()->db();
...@@ -311,18 +366,22 @@ final class RegistrationWizardService ...@@ -311,18 +366,22 @@ final class RegistrationWizardService
return ['success' => false, 'error' => 'يجب اختيار النشاط أولاً']; return ['success' => false, 'error' => 'يجب اختيار النشاط أولاً'];
} }
$totalFees = (float) $registration['total_fees']; $subscriptionAmount = (float) ($registration['subscription_amount'] ?? 0);
if ($totalFees <= 0) { $cardFee = (float) $registration['card_fee'];
$formFee = (float) $registration['form_fee'];
$totalSubscription = $subscriptionAmount + $cardFee + $formFee;
if ($totalSubscription <= 0) {
return ['success' => false, 'error' => 'إجمالي الرسوم غير صالح']; return ['success' => false, 'error' => 'إجمالي الرسوم غير صالح'];
} }
$memberId = (int) ($registration['member_id'] ?? 0); $memberId = (int) ($registration['member_id'] ?? 0);
$description = 'تسجيل نشاط رياضي — ' . ($registration['full_name_ar'] ?? ''); $description = 'اشتراك نشاط رياضي — ' . ($registration['full_name_ar'] ?? '');
$result = PaymentRequestService::createRequest([ $result = PaymentRequestService::createRequest([
'member_id' => $memberId, 'member_id' => $memberId,
'payment_type' => 'sports_registration', 'payment_type' => 'sports_subscription',
'amount' => (string) $totalFees, 'amount' => (string) $totalSubscription,
'description_ar' => $description, 'description_ar' => $description,
'related_entity_type' => 'sa_registrations', 'related_entity_type' => 'sa_registrations',
'related_entity_id' => $registrationId, 'related_entity_id' => $registrationId,
...@@ -343,7 +402,7 @@ final class RegistrationWizardService ...@@ -343,7 +402,7 @@ final class RegistrationWizardService
'success' => true, 'success' => true,
'request_id' => $result['request_id'], 'request_id' => $result['request_id'],
'request_number' => $result['request_number'], 'request_number' => $result['request_number'],
'amount' => $totalFees, 'amount' => $totalSubscription,
]; ];
} }
...@@ -375,6 +434,10 @@ final class RegistrationWizardService ...@@ -375,6 +434,10 @@ final class RegistrationWizardService
$cardNumber = self::generateCardNumber(); $cardNumber = self::generateCardNumber();
$qrData = QRCodeGenerator::encode('SA:' . $cardNumber); $qrData = QRCodeGenerator::encode('SA:' . $cardNumber);
$months = max(1, (int) ($registration['subscription_months'] ?? 1));
$validFrom = date('Y-m-d');
$validUntil = date('Y-m-d', strtotime("+{$months} months -1 day"));
$cardId = $db->insert('sa_player_cards', [ $cardId = $db->insert('sa_player_cards', [
'card_number' => $cardNumber, 'card_number' => $cardNumber,
'player_id' => (int) $registration['player_id'], 'player_id' => (int) $registration['player_id'],
...@@ -382,8 +445,8 @@ final class RegistrationWizardService ...@@ -382,8 +445,8 @@ final class RegistrationWizardService
'card_type' => 'standard', 'card_type' => 'standard',
'status' => 'active', 'status' => 'active',
'qr_code_data' => $qrData, 'qr_code_data' => $qrData,
'valid_from' => date('Y-m-d'), 'valid_from' => $validFrom,
'valid_until' => null, 'valid_until' => $validUntil,
'photo_path' => $registration['photo_path'], 'photo_path' => $registration['photo_path'],
'issued_by' => $employee ? (int) $employee->id : null, 'issued_by' => $employee ? (int) $employee->id : null,
'branch_id' => $branch ? (int) $branch['id'] : null, 'branch_id' => $branch ? (int) $branch['id'] : null,
......
...@@ -7,111 +7,168 @@ $clubSubtitle = BrandingService::subtitle(); ...@@ -7,111 +7,168 @@ $clubSubtitle = BrandingService::subtitle();
$logoUrl = BrandingService::logo(); $logoUrl = BrandingService::logo();
?> ?>
<?php $__template->layout('Layout.print'); ?> <?php $__template->layout('Layout.print'); ?>
<?php $__template->section('title'); ?>استمارة تسجيل النشاط الرياضي — <?= e($registration['registration_number']) ?><?php $__template->endSection(); ?> <?php $__template->section('title'); ?>استمارة اشتراك النشاط الرياضي — <?= e($registration['registration_number']) ?><?php $__template->endSection(); ?>
<?php $__template->section('content'); ?> <?php $__template->section('content'); ?>
<style> <style>
@media print { body { margin: 0; } .no-print { display: none !important; } } @media print { body { margin: 0; } .no-print { display: none !important; } @page { size: A4; margin: 10mm; } }
.reg-form { width: 210mm; min-height: 297mm; margin: 0 auto; padding: 15mm 20mm; font-family: 'Cairo', Arial, sans-serif; direction: rtl; font-size: 13px; color: #1A1A2E; } .sa-form { width: 210mm; min-height: 297mm; margin: 0 auto; padding: 12mm 15mm; font-family: 'Cairo', Arial, sans-serif; direction: rtl; font-size: 12px; color: #1A1A2E; position: relative; border: 2px solid #1A1A2E; }
.reg-form .header { text-align: center; margin-bottom: 20px; border-bottom: 3px solid #1A1A2E; padding-bottom: 15px; } .sa-form .header { display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid #1A1A2E; padding-bottom: 10px; margin-bottom: 12px; }
.reg-form .header img { max-height: 50px; margin-bottom: 8px; } .sa-form .header .center { text-align: center; flex: 1; }
.reg-form .header h1 { font-size: 20px; margin: 5px 0 3px; } .sa-form .header .center h1 { font-size: 16px; margin: 0; }
.reg-form .header h2 { font-size: 14px; color: #6B7280; margin: 0; font-weight: 400; } .sa-form .header .center h2 { font-size: 11px; margin: 3px 0 0; color: #4B5563; font-weight: 400; }
.reg-form .form-title { text-align: center; font-size: 18px; font-weight: 700; margin: 15px 0; padding: 8px; background: #F3F4F6; border-radius: 6px; } .sa-form .header .logo { width: 55px; height: 55px; }
.reg-form .info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 20px; margin-bottom: 20px; } .sa-form .header .logo img { width: 100%; height: 100%; object-fit: contain; }
.reg-form .info-row { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px dotted #D1D5DB; } .sa-form .form-number { position: absolute; top: 12mm; left: 15mm; font-size: 18px; font-weight: 800; color: #DC2626; direction: ltr; }
.reg-form .info-row .label { font-weight: 600; min-width: 120px; color: #374151; } .sa-form .form-type { text-align: center; font-size: 15px; font-weight: 700; margin: 10px 0; padding: 6px; border: 1px solid #1A1A2E; background: #F9FAFB; }
.reg-form .info-row .value { flex: 1; } .sa-form .form-subtitle { text-align: center; font-size: 12px; color: #6B7280; margin: 0 0 12px; }
.reg-form .photo-section { float: left; margin: 0 0 15px 15px; } .sa-form .player-section { display: flex; gap: 15px; margin-bottom: 12px; }
.reg-form .photo-section img { width: 100px; height: 120px; object-fit: cover; border: 2px solid #1A1A2E; border-radius: 6px; } .sa-form .player-data { flex: 1; }
.reg-form .photo-section .no-photo { width: 100px; height: 120px; border: 2px solid #D1D5DB; border-radius: 6px; display: flex; align-items: center; justify-content: center; color: #9CA3AF; font-size: 11px; } .sa-form .player-photo { width: 90px; }
.reg-form .fee-table { width: 100%; border-collapse: collapse; margin: 15px 0; } .sa-form .player-photo img { width: 90px; height: 110px; object-fit: cover; border: 1.5px solid #1A1A2E; }
.reg-form .fee-table th, .reg-form .fee-table td { border: 1px solid #D1D5DB; padding: 8px 12px; text-align: right; } .sa-form .player-photo .empty { width: 90px; height: 110px; border: 1.5px dashed #9CA3AF; display: flex; align-items: center; justify-content: center; font-size: 10px; color: #9CA3AF; }
.reg-form .fee-table th { background: #F3F4F6; font-weight: 600; } .sa-form .field-row { display: flex; border-bottom: 1px dotted #9CA3AF; padding: 5px 0; margin-bottom: 2px; }
.reg-form .fee-table .total-row { background: #EFF6FF; font-weight: 700; } .sa-form .field-row .lbl { font-weight: 600; min-width: 100px; font-size: 11px; color: #374151; }
.reg-form .signatures { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-top: 40px; text-align: center; } .sa-form .field-row .val { flex: 1; font-size: 12px; }
.reg-form .signatures .sig-box { border-top: 1px solid #1A1A2E; padding-top: 8px; margin-top: 50px; } .sa-form .activity-box { border: 1px solid #1A1A2E; padding: 10px; margin: 10px 0; border-radius: 4px; }
.reg-form .qr-section { position: absolute; bottom: 20mm; left: 20mm; } .sa-form .activity-box h4 { margin: 0 0 6px; font-size: 13px; }
.reg-form .reg-number { position: absolute; top: 15mm; left: 20mm; font-size: 12px; direction: ltr; color: #6B7280; } .sa-form .fee-tbl { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 11px; }
.sa-form .fee-tbl th, .sa-form .fee-tbl td { border: 1px solid #9CA3AF; padding: 5px 8px; }
.sa-form .fee-tbl th { background: #F3F4F6; font-weight: 600; }
.sa-form .fee-tbl .total { background: #EFF6FF; font-weight: 700; font-size: 12px; }
.sa-form .terms { border: 1px solid #D1D5DB; padding: 10px; margin: 12px 0; font-size: 10px; line-height: 1.8; }
.sa-form .terms h4 { margin: 0 0 5px; font-size: 11px; }
.sa-form .terms ol { margin: 0; padding-right: 18px; }
.sa-form .signatures { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 20px; font-size: 11px; }
.sa-form .sig-line { border-bottom: 1px solid #1A1A2E; height: 30px; margin-top: 5px; }
.sa-form .qr-corner { position: absolute; bottom: 12mm; left: 15mm; }
.sa-form .date-corner { position: absolute; bottom: 12mm; right: 15mm; font-size: 11px; }
.sa-form .form-fee-badge { display: inline-block; padding: 3px 10px; background: #DC2626; color: #fff; font-weight: 700; font-size: 11px; border-radius: 4px; margin-right: 10px; }
</style> </style>
<div class="no-print" style="text-align:center;padding:10px;"> <div class="no-print" style="text-align:center;padding:10px;">
<button onclick="window.print()" style="padding:8px 20px;background:#2563EB;color:#fff;border:none;border-radius:6px;cursor:pointer;font-size:14px;">طباعة</button> <button onclick="window.print()" style="padding:10px 24px;background:#2563EB;color:#fff;border:none;border-radius:8px;cursor:pointer;font-size:14px;font-weight:600;">طباعة</button>
<a href="/sa/registration/<?= (int) $registration['id'] ?>" style="margin-right:10px;color:#6B7280;font-size:14px;">رجوع</a> <a href="/sa/registration/<?= (int) $registration['id'] ?>" style="margin-right:10px;color:#6B7280;font-size:14px;">رجوع</a>
</div> </div>
<div class="reg-form" style="position:relative;"> <div class="sa-form">
<div class="reg-number"><?= e($registration['registration_number']) ?></div> <!-- Form Number -->
<div class="form-number"><?= e($registration['registration_number']) ?></div>
<!-- Header --> <!-- Header -->
<div class="header"> <div class="header">
<?php if ($logoUrl): ?><img src="<?= e($logoUrl) ?>" alt="Logo"><?php endif; ?> <div class="logo">
<h1><?= e($clubNameAr) ?></h1> <?php if ($logoUrl): ?><img src="<?= e($logoUrl) ?>" alt=""><?php endif; ?>
<h2><?= e($clubSubtitle) ?></h2> </div>
<div class="center">
<h1><?= e($clubNameAr) ?></h1>
<h2><?= e($clubNameEn ?: $clubSubtitle) ?></h2>
</div>
<div class="logo" style="text-align:left;">
<div style="font-size:9px;color:#6B7280;text-align:center;">وزارة الشباب<br>والرياضة</div>
</div>
</div> </div>
<div class="form-title">استمارة تسجيل النشاط الرياضي</div> <!-- Form Title -->
<div class="form-type">نموذج: اشتراك في النشاط الرياضي</div>
<!-- Photo --> <div class="form-subtitle">
<div class="photo-section"> ( <?= $registration['player_type'] === 'member' ? 'أعضاء' : 'غير أعضاء' ?> )
<?php if ($registration['photo_path']): ?> <span class="form-fee-badge">قيمة الاستمارة: <?= number_format((float) $registration['registration_fee'], 0) ?> جنيه</span>
<img src="/<?= e($registration['photo_path']) ?>" alt="صورة اللاعب">
<?php else: ?>
<div class="no-photo">لا توجد صورة</div>
<?php endif; ?>
</div> </div>
<!-- Player Data --> <!-- Player Data + Photo -->
<div class="info-grid"> <div class="player-section">
<div class="info-row"><span class="label">الاسم:</span><span class="value"><?= e($registration['full_name_ar']) ?></span></div> <div class="player-data">
<div class="info-row"><span class="label">النوع:</span><span class="value"><?= $registration['player_type'] === 'member' ? 'عضو' : 'غير عضو' ?></span></div> <div class="field-row"><span class="lbl">بيانات اللاعب</span><span class="val"></span></div>
<div class="info-row"><span class="label">الرقم القومي:</span><span class="value" style="direction:ltr;text-align:right;"><?= e($registration['player_nid'] ?? '—') ?></span></div> <div class="field-row"><span class="lbl">الاسم:</span><span class="val"><?= e($registration['full_name_ar']) ?></span></div>
<div class="info-row"><span class="label">تاريخ الميلاد:</span><span class="value"><?= e($registration['date_of_birth'] ?? '—') ?></span></div> <?php if (!empty($registration['full_name_en'])): ?>
<div class="info-row"><span class="label">النوع:</span><span class="value"><?= ($registration['gender'] ?? '') === 'male' ? 'ذكر' : (($registration['gender'] ?? '') === 'female' ? 'أنثى' : '—') ?></span></div> <div class="field-row"><span class="lbl">الاسم بالإنجليزي:</span><span class="val" style="direction:ltr;text-align:right;"><?= e($registration['full_name_en']) ?></span></div>
<div class="info-row"><span class="label">الهاتف:</span><span class="value" style="direction:ltr;text-align:right;"><?= e($registration['phone'] ?? '—') ?></span></div> <?php endif; ?>
<div class="info-row"><span class="label">ولي الأمر:</span><span class="value"><?= e($registration['guardian_name'] ?? '—') ?></span></div> <div class="field-row"><span class="lbl">الرقم القومي:</span><span class="val" style="direction:ltr;text-align:right;letter-spacing:1px;"><?= e($registration['player_nid'] ?? '—') ?></span></div>
<div class="info-row"><span class="label">هاتف ولي الأمر:</span><span class="value" style="direction:ltr;text-align:right;"><?= e($registration['guardian_phone'] ?? '—') ?></span></div> <div class="field-row"><span class="lbl">تاريخ الميلاد:</span><span class="val"><?= e($registration['date_of_birth'] ?? '—') ?></span></div>
<div class="info-row"><span class="label">الرقم التسلسلي:</span><span class="value" style="direction:ltr;text-align:right;"><?= e($registration['registration_serial'] ?? '—') ?></span></div> <div class="field-row"><span class="lbl">النوع:</span><span class="val"><?= ($registration['gender'] ?? '') === 'male' ? 'ذكر' : (($registration['gender'] ?? '') === 'female' ? 'أنثى' : '—') ?></span></div>
<div class="field-row"><span class="lbl">تليفون ولي الأمر:</span><span class="val" style="direction:ltr;text-align:right;"><?= e($registration['guardian_phone'] ?? $registration['phone'] ?? '—') ?></span></div>
<div class="field-row"><span class="lbl">اسم ولي الأمر:</span><span class="val"><?= e($registration['guardian_name'] ?? '—') ?></span></div>
<div class="field-row"><span class="lbl">منطقة السكن:</span><span class="val">.............................</span></div>
</div>
<div class="player-photo">
<?php if ($registration['photo_path']): ?>
<img src="/<?= e($registration['photo_path']) ?>" alt="">
<?php else: ?>
<div class="empty">2 صورة شخصية</div>
<?php endif; ?>
<div style="text-align:center;font-size:9px;margin-top:3px;color:#6B7280;">صورة اللاعب</div>
</div>
</div> </div>
<div style="clear:both;"></div>
<!-- Activity Info --> <!-- Activity Info -->
<?php if ($group): ?> <?php if ($group): ?>
<div style="margin:15px 0;padding:12px;background:#F0FDF4;border:1px solid #BBF7D0;border-radius:6px;"> <div class="activity-box">
<strong>النشاط:</strong> <?= e($group['discipline_name'] ?? '') ?><?= e($group['name_ar']) ?> <h4>بيانات النشاط الرياضي:</h4>
<?php if (!empty($group['program_name'])): ?><br><strong>البرنامج:</strong> <?= e($group['program_name']) ?><?php endif; ?> <div class="field-row"><span class="lbl">نوع النشاط:</span><span class="val"><?= e($group['discipline_name'] ?? '') ?></span></div>
<div class="field-row"><span class="lbl">المجموعة:</span><span class="val"><?= e($group['name_ar']) ?></span></div>
<?php if (!empty($group['program_name'])): ?>
<div class="field-row"><span class="lbl">البرنامج:</span><span class="val"><?= e($group['program_name']) ?></span></div>
<?php endif; ?>
</div> </div>
<?php endif; ?> <?php endif; ?>
<!-- Fee Table --> <!-- Fee Table -->
<table class="fee-table"> <table class="fee-tbl">
<thead> <thead>
<tr><th>البند</th><th style="width:120px;">المبلغ</th></tr> <tr><th>البند</th><th style="width:100px;">المبلغ</th></tr>
</thead> </thead>
<tbody> <tbody>
<tr><td>رسوم التسجيل (<?= $registration['player_type'] === 'member' ? 'عضو' : 'غير عضو' ?>)</td><td><?= money((float) $registration['registration_fee']) ?></td></tr> <tr><td>رسوم استمارة الاشتراك (<?= $registration['player_type'] === 'member' ? 'عضو' : 'غير عضو' ?>)</td><td><?= number_format((float) $registration['registration_fee'], 0) ?> ج.م</td></tr>
<tr><td>رسوم الكارت</td><td><?= money((float) $registration['card_fee']) ?></td></tr> <tr><td>رسوم الكارت</td><td><?= number_format((float) $registration['card_fee'], 0) ?> ج.م</td></tr>
<tr><td>رسوم الاستمارة</td><td><?= money((float) $registration['form_fee']) ?></td></tr> <tr><td>رسوم استمارة النشاط</td><td><?= number_format((float) $registration['form_fee'], 0) ?> ج.م</td></tr>
<?php if ((float) ($registration['subscription_amount'] ?? 0) > 0): ?> <?php if ((float) ($registration['subscription_amount'] ?? 0) > 0): ?>
<tr><td>اشتراك النشاط (شهري)</td><td><?= money((float) $registration['subscription_amount']) ?></td></tr> <tr><td>اشتراك النشاط</td><td><?= number_format((float) $registration['subscription_amount'], 0) ?> ج.م</td></tr>
<?php endif; ?> <?php endif; ?>
<tr class="total-row"><td>الإجمالي</td><td><?= money((float) $registration['total_fees']) ?></td></tr> <tr class="total"><td>الإجمالي</td><td><?= number_format((float) $registration['total_fees'], 0) ?> ج.م</td></tr>
</tbody> </tbody>
</table> </table>
<!-- Terms & Conditions (matching physical form) -->
<div class="terms">
<h4>التعليمات وقواعد الاشتراك في الأنشطة الرياضية أو الأكاديمية:</h4>
<ol>
<li>الاستمارة هي أساسي للاشتراك في الأنشطة الرياضية بالنادي ويرضى ويلتزم اللاعب/ولي الأمر بقواعد وشروط التبعية الكشف الطبي من الطب الرياضي وقبول شهادات شهادات الجهات الأخرى (المعاهد ومراكز الطب ويتم قبول الرياضة بمعرفة وزارة الشباب والرياضة).</li>
<li>بالاستمارة يتم شهر + أصل الصلاحية منذ تاريخ التمديد حتى نهاية الجمعية ويتضمن كل شهور السداد المقدمة (المبدئية وشرطها التبعية للنادي يتضمن كافة شهور الاشتراك واستلام الكارنية بالنادي).</li>
<li>في حالة تسديد أو شراء الاشتراك بنفس العام يتم دفع أول شهر + أصل العقد كاملاً مقدماً منذ تاريخ + عدد أشهر المتبقية والتي تحدد بجدول السداد المبدئي.</li>
<li>رسوم دفع (50 جنيه) أن يعلن أن تاريخ 1 + أصل العقد منذ تسديد قيمة الشهادة الجمعية مستحقات فيها كل شهر الاستحقاق بعد بيان دفع.</li>
<li>(30 جنيه) رسم إدارى للكارنية بعد بيان فقط.</li>
<li>ضرورة ظهور بطاقة الحضور كارنيه خاصة بالنشاط الرياضي إدارة اللاعب حتى الشروط والأحكام باب النادي والنشاط كل شهر في النادي في حالة والأمن.</li>
<li>اللاعب يلتزي بالنشاط الرياضي الأقصى 20 من المبوابات الأولي بالحد قبل بدء التدريب بما لا يقل عن 30 دقيقة كحد الاشتراكي ومستعداً لممارسة التدريب وتطبيقات النشاط بعد بيان تمام ومعتمدة بحالته الصحية بالاستمارة إلى أن يتوفر إجراء الكشف الطبي رسمياً.</li>
<li>الاستمارة تستعمل لأغراض التسجيل فقط ومسلتزمات المصاريف المتعلقة بها.</li>
</ol>
</div>
<!-- Declaration -->
<div style="font-size:11px;margin:10px 0;padding:8px;border:1px solid #D1D5DB;border-radius:4px;">
<strong>أنا أوجه/السيدة/السادة:</strong> <?= e($registration['guardian_name'] ?? $registration['full_name_ar']) ?>
...أقر أنني مسؤول/ة عن المبينات، وأصرح بالمسؤلية الكاملة والتصريحات ومستلزمات الحالات وتطبيقات النشاط الرياضي أقصى والمنضمة إلى إدارة النادي ومستلزمات النشاط وملحقاته.
</div>
<!-- Signatures --> <!-- Signatures -->
<div class="signatures"> <div class="signatures">
<div><div class="sig-box">توقيع اللاعب / ولي الأمر</div></div> <div>
<div><div class="sig-box">مسؤول التسجيل</div></div> <div style="font-weight:600;">توقيع ولي الأمر:</div>
<div><div class="sig-box">مدير النشاط الرياضي</div></div> <div class="sig-line"></div>
<div style="font-size:10px;color:#6B7280;margin-top:3px;">التاريخ: ....../....../......</div>
</div>
<div>
<div style="font-weight:600;">توقيع إدارة النادي:</div>
<div class="sig-line"></div>
<div style="font-size:10px;color:#6B7280;margin-top:3px;">التاريخ: ....../....../......</div>
</div>
</div> </div>
<!-- QR --> <!-- QR -->
<div class="qr-section"><?= $qrSvg ?></div> <div class="qr-corner"><?= $qrSvg ?></div>
<!-- Date --> <!-- Date -->
<div style="position:absolute;bottom:20mm;right:20mm;font-size:12px;color:#6B7280;"> <div class="date-corner">
التاريخ: <?= date('Y-m-d') ?> تاريخ التسجيل: <?= date('Y/m/d', strtotime($registration['created_at'])) ?>
</div> </div>
</div> </div>
<?php $__template->endSection(); ?> <?php $__template->endSection(); ?>
...@@ -9,23 +9,23 @@ ...@@ -9,23 +9,23 @@
<?php if (isset($registration)): ?> <?php if (isset($registration)): ?>
<!-- Wizard Steps View --> <!-- Wizard Steps View -->
<div id="wizardApp" data-registration-id="<?= (int) $registration['id'] ?>" data-step="<?= $step ?? 2 ?>"> <div id="wizardApp" data-registration-id="<?= (int) $registration['id'] ?>" data-step="<?= $step ?? 1 ?>">
<!-- Progress Bar --> <!-- Progress Bar -->
<div class="card" style="margin-bottom:20px;padding:20px;"> <div class="card" style="margin-bottom:16px;padding:16px;">
<div style="display:flex;justify-content:space-between;align-items:center;position:relative;"> <div style="display:flex;justify-content:space-between;align-items:center;position:relative;">
<div style="position:absolute;top:50%;left:40px;right:40px;height:3px;background:#E5E7EB;z-index:0;transform:translateY(-50%);"></div> <div style="position:absolute;top:50%;left:40px;right:40px;height:3px;background:#E5E7EB;z-index:0;transform:translateY(-50%);"></div>
<?php <?php
$steps = ['الرقم القومي', 'الصورة', 'النشاط', 'الدفع', 'الاستلام']; $steps = ['الاستمارة', 'الصورة', 'النشاط', 'الدفع', 'الاستلام'];
foreach ($steps as $i => $label): foreach ($steps as $i => $label):
$stepNum = $i + 1; $stepNum = $i + 1;
$isActive = $stepNum == ($step ?? 2); $isActive = $stepNum == ($step ?? 1);
$isComplete = $stepNum < ($step ?? 2); $isComplete = $stepNum < ($step ?? 1);
$bgColor = $isComplete ? '#059669' : ($isActive ? '#2563EB' : '#E5E7EB'); $bgColor = $isComplete ? '#059669' : ($isActive ? '#2563EB' : '#E5E7EB');
$textColor = ($isComplete || $isActive) ? '#fff' : '#9CA3AF'; $textColor = ($isComplete || $isActive) ? '#fff' : '#9CA3AF';
?> ?>
<div style="text-align:center;position:relative;z-index:1;"> <div style="text-align:center;position:relative;z-index:1;">
<div style="width:36px;height:36px;border-radius:50%;background:<?= $bgColor ?>;color:<?= $textColor ?>;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:14px;margin:0 auto;"> <div style="width:40px;height:40px;border-radius:50%;background:<?= $bgColor ?>;color:<?= $textColor ?>;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:15px;margin:0 auto;">
<?= $isComplete ? '✓' : $stepNum ?> <?= $isComplete ? '✓' : $stepNum ?>
</div> </div>
<div style="font-size:11px;margin-top:6px;color:<?= $isActive ? '#2563EB' : '#6B7280' ?>;font-weight:<?= $isActive ? '700' : '400' ?>;"><?= $label ?></div> <div style="font-size:11px;margin-top:6px;color:<?= $isActive ? '#2563EB' : '#6B7280' ?>;font-weight:<?= $isActive ? '700' : '400' ?>;"><?= $label ?></div>
...@@ -35,79 +35,129 @@ ...@@ -35,79 +35,129 @@
</div> </div>
<!-- Player Info Summary --> <!-- Player Info Summary -->
<div class="card" style="margin-bottom:20px;"> <div class="card" style="margin-bottom:16px;">
<div style="padding:15px 20px;display:flex;align-items:center;gap:15px;border-bottom:1px solid #E5E7EB;"> <div style="padding:14px 16px;display:flex;align-items:center;gap:12px;border-bottom:1px solid #E5E7EB;">
<div style="width:60px;height:60px;border-radius:8px;overflow:hidden;background:#F3F4F6;flex-shrink:0;"> <div style="width:56px;height:56px;border-radius:8px;overflow:hidden;background:#F3F4F6;flex-shrink:0;">
<?php if ($registration['photo_path']): ?> <?php if ($registration['photo_path']): ?>
<img src="/<?= e($registration['photo_path']) ?>" style="width:100%;height:100%;object-fit:cover;" alt=""> <img src="/<?= e($registration['photo_path']) ?>" style="width:100%;height:100%;object-fit:cover;" alt="">
<?php else: ?> <?php else: ?>
<div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#9CA3AF;"><i data-lucide="user" style="width:28px;height:28px;"></i></div> <div style="width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#9CA3AF;"><i data-lucide="user" style="width:24px;height:24px;"></i></div>
<?php endif; ?> <?php endif; ?>
</div> </div>
<div style="flex:1;"> <div style="flex:1;min-width:0;">
<div style="font-size:16px;font-weight:700;color:#1A1A2E;"><?= e($registration['full_name_ar']) ?></div> <div style="font-size:16px;font-weight:700;color:#1A1A2E;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><?= e($registration['full_name_ar']) ?></div>
<div style="font-size:12px;color:#6B7280;margin-top:2px;"> <div style="font-size:12px;color:#6B7280;margin-top:2px;">
<?= $registration['player_type'] === 'member' ? 'عضو' : 'غير عضو' ?> <span style="padding:2px 6px;border-radius:4px;font-size:11px;font-weight:600;background:<?= $registration['player_type'] === 'member' ? '#ECFDF5' : '#FEF3C7' ?>;color:<?= $registration['player_type'] === 'member' ? '#059669' : '#D97706' ?>;">
<?php if ($registration['player_nid']): ?><?= e($registration['player_nid']) ?><?php endif; ?> <?= $registration['player_type'] === 'member' ? 'عضو' : 'غير عضو' ?>
</span>
<?php if ($registration['player_nid']): ?><span style="margin-right:6px;direction:ltr;display:inline-block;"><?= e($registration['player_nid']) ?></span><?php endif; ?>
</div> </div>
</div> </div>
<div style="text-align:left;"> <div style="text-align:left;flex-shrink:0;">
<span style="font-size:11px;color:#6B7280;">رقم التسجيل</span> <div style="font-size:11px;color:#6B7280;">رقم التسجيل</div>
<div style="font-size:13px;font-weight:600;direction:ltr;"><?= e($registration['registration_number']) ?></div> <div style="font-size:12px;font-weight:600;direction:ltr;"><?= e($registration['registration_number']) ?></div>
</div>
</div>
</div>
<!-- Step 1: Form Fee Payment (استمارة اشتراك) -->
<div id="step-form" class="wizard-step" style="<?= ($step ?? 1) == 1 ? '' : 'display:none;' ?>">
<div class="card" style="margin-bottom:16px;">
<div style="padding:16px 20px;border-bottom:1px solid #E5E7EB;">
<h3 style="margin:0;font-size:16px;font-weight:600;"><i data-lucide="file-text" style="width:18px;height:18px;vertical-align:middle;margin-left:6px;"></i> استمارة اشتراك النشاط الرياضي</h3>
</div>
<div style="padding:24px;text-align:center;">
<div style="max-width:400px;margin:0 auto;">
<div style="width:80px;height:80px;border-radius:50%;background:#EFF6FF;margin:0 auto 16px;display:flex;align-items:center;justify-content:center;">
<i data-lucide="receipt" style="width:40px;height:40px;color:#2563EB;"></i>
</div>
<p style="font-size:15px;color:#374151;margin:0 0 8px;font-weight:600;">رسوم استمارة الاشتراك</p>
<p style="font-size:13px;color:#6B7280;margin:0 0 20px;">يجب سداد رسوم الاستمارة قبل إتمام التسجيل والتقاط الصورة</p>
<div style="font-size:36px;font-weight:800;color:#2563EB;margin-bottom:8px;"><?= number_format((float) $registration['registration_fee'], 0) ?> <span style="font-size:16px;">ج.م</span></div>
<div style="font-size:12px;color:#6B7280;margin-bottom:24px;"><?= $registration['player_type'] === 'member' ? 'رسوم عضو' : 'رسوم غير عضو' ?></div>
<?php if (($registration['form_payment_status'] ?? 'unpaid') === 'pending'): ?>
<div style="padding:16px;background:#FEF3C7;border-radius:10px;">
<i data-lucide="clock" style="width:20px;height:20px;color:#D97706;vertical-align:middle;margin-left:6px;"></i>
<span style="color:#92400E;font-weight:600;">تم إرسال طلب الدفع — بانتظار التحصيل من الخزينة</span>
</div>
<?php else: ?>
<button type="button" id="btnPayForm" class="btn btn-primary" style="width:100%;padding:16px;font-size:16px;font-weight:700;border-radius:12px;min-height:56px;">
<i data-lucide="banknote" style="width:20px;height:20px;vertical-align:middle;margin-left:6px;"></i> إرسال للخزينة — <?= number_format((float) $registration['registration_fee'], 0) ?> ج.م
</button>
<?php endif; ?>
</div>
</div> </div>
</div> </div>
</div> </div>
<!-- Step 2: Photo Capture --> <!-- Step 2: Photo Capture -->
<div id="step-photo" class="wizard-step" style="<?= ($step ?? 2) == 2 ? '' : 'display:none;' ?>"> <div id="step-photo" class="wizard-step" style="<?= ($step ?? 1) == 2 ? '' : 'display:none;' ?>">
<div class="card" style="margin-bottom:20px;"> <div class="card" style="margin-bottom:16px;">
<div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;"> <div style="padding:16px 20px;border-bottom:1px solid #E5E7EB;">
<h3 style="margin:0;font-size:16px;font-weight:600;"><i data-lucide="camera" style="width:18px;height:18px;vertical-align:middle;margin-left:6px;"></i> التقاط الصورة</h3> <h3 style="margin:0;font-size:16px;font-weight:600;"><i data-lucide="camera" style="width:18px;height:18px;vertical-align:middle;margin-left:6px;"></i> التقاط الصورة</h3>
</div> </div>
<div style="padding:20px;text-align:center;"> <div style="padding:24px;text-align:center;">
<div id="photoPreview" style="width:200px;height:200px;border-radius:12px;background:#F3F4F6;margin:0 auto 15px;overflow:hidden;display:flex;align-items:center;justify-content:center;"> <div id="photoPreview" style="width:200px;height:200px;border-radius:12px;background:#F3F4F6;margin:0 auto 16px;overflow:hidden;display:flex;align-items:center;justify-content:center;">
<?php if ($registration['photo_path']): ?> <?php if ($registration['photo_path']): ?>
<img src="/<?= e($registration['photo_path']) ?>" style="width:100%;height:100%;object-fit:cover;"> <img src="/<?= e($registration['photo_path']) ?>" style="width:100%;height:100%;object-fit:cover;">
<?php else: ?> <?php else: ?>
<i data-lucide="camera" style="width:48px;height:48px;color:#D1D5DB;"></i> <i data-lucide="camera" style="width:48px;height:48px;color:#D1D5DB;"></i>
<?php endif; ?> <?php endif; ?>
</div> </div>
<video id="webcamVideo" style="display:none;width:200px;height:200px;border-radius:12px;object-fit:cover;margin:0 auto 15px;"></video> <video id="webcamVideo" style="display:none;width:200px;height:200px;border-radius:12px;object-fit:cover;margin:0 auto 16px;"></video>
<canvas id="webcamCanvas" style="display:none;"></canvas> <canvas id="webcamCanvas" style="display:none;"></canvas>
<div style="display:flex;gap:10px;justify-content:center;flex-wrap:wrap;"> <div style="display:flex;gap:12px;justify-content:center;flex-wrap:wrap;">
<button type="button" id="btnStartWebcam" class="btn btn-outline"><i data-lucide="video" style="width:14px;height:14px;vertical-align:middle;margin-left:4px;"></i> كاميرا</button> <button type="button" id="btnStartWebcam" class="btn btn-outline" style="padding:14px 20px;font-size:14px;min-height:50px;border-radius:10px;">
<button type="button" id="btnCaptureWebcam" class="btn btn-primary" style="display:none;"><i data-lucide="camera" style="width:14px;height:14px;vertical-align:middle;margin-left:4px;"></i> التقاط</button> <i data-lucide="video" style="width:18px;height:18px;vertical-align:middle;margin-left:6px;"></i> كاميرا
<label class="btn btn-outline" style="cursor:pointer;"><i data-lucide="upload" style="width:14px;height:14px;vertical-align:middle;margin-left:4px;"></i> رفع ملف<input type="file" id="photoFileInput" accept="image/*" style="display:none;"></label> </button>
<button type="button" id="btnCaptureWebcam" class="btn btn-primary" style="display:none;padding:14px 20px;font-size:14px;min-height:50px;border-radius:10px;">
<i data-lucide="camera" style="width:18px;height:18px;vertical-align:middle;margin-left:6px;"></i> التقاط
</button>
<label class="btn btn-outline" style="cursor:pointer;padding:14px 20px;font-size:14px;min-height:50px;border-radius:10px;">
<i data-lucide="upload" style="width:18px;height:18px;vertical-align:middle;margin-left:6px;"></i> رفع ملف
<input type="file" id="photoFileInput" accept="image/*" style="display:none;">
</label>
</div> </div>
<div id="photoStatus" style="margin-top:10px;font-size:12px;display:none;"></div> <div id="photoStatus" style="margin-top:12px;font-size:13px;display:none;"></div>
</div> </div>
</div> </div>
<div style="display:flex;gap:10px;"> <button type="button" id="btnPhotoNext" class="btn btn-primary" style="width:100%;padding:16px;font-size:16px;font-weight:700;border-radius:12px;min-height:56px;" <?= (int) $registration['photo_captured'] ? '' : 'disabled' ?>>
<button type="button" id="btnPhotoNext" class="btn btn-primary" <?= (int) $registration['photo_captured'] ? '' : 'disabled' ?>><i data-lucide="arrow-left" style="width:14px;height:14px;vertical-align:middle;margin-left:4px;"></i> التالي — اختيار النشاط</button> <i data-lucide="arrow-left" style="width:18px;height:18px;vertical-align:middle;margin-left:6px;"></i> التالي — اختيار النشاط
</div> </button>
</div> </div>
<!-- Step 3: Activity/Group Selection --> <!-- Step 3: Activity/Group Selection -->
<div id="step-activity" class="wizard-step" style="<?= ($step ?? 2) == 3 ? '' : 'display:none;' ?>"> <div id="step-activity" class="wizard-step" style="<?= ($step ?? 1) == 3 ? '' : 'display:none;' ?>">
<div class="card" style="margin-bottom:20px;"> <div class="card" style="margin-bottom:16px;">
<div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;"> <div style="padding:16px 20px;border-bottom:1px solid #E5E7EB;">
<h3 style="margin:0;font-size:16px;font-weight:600;"><i data-lucide="trophy" style="width:18px;height:18px;vertical-align:middle;margin-left:6px;"></i> اختيار النشاط والمجموعة</h3> <h3 style="margin:0;font-size:16px;font-weight:600;"><i data-lucide="trophy" style="width:18px;height:18px;vertical-align:middle;margin-left:6px;"></i> اختيار النشاط والمجموعة</h3>
</div> </div>
<div style="padding:20px;"> <div style="padding:16px;">
<div style="margin-bottom:15px;"> <div style="margin-bottom:12px;">
<input type="text" id="groupSearch" class="form-input" placeholder="ابحث عن نشاط أو مجموعة..." style="max-width:400px;"> <input type="text" id="groupSearch" class="form-input" placeholder="ابحث عن نشاط أو مجموعة..." style="padding:14px;font-size:15px;border-radius:10px;">
</div> </div>
<div id="groupsList" style="display:grid;grid-template-columns:repeat(auto-fill, minmax(280px, 1fr));gap:12px;"> <div id="groupsList" style="display:grid;grid-template-columns:1fr;gap:10px;max-height:50vh;overflow-y:auto;-webkit-overflow-scrolling:touch;">
<?php foreach ($groups as $g): ?> <?php foreach ($groups as $g): ?>
<div class="group-option" data-group-id="<?= (int) $g['id'] ?>" data-name="<?= e($g['name_ar'] . ' ' . ($g['discipline_name'] ?? '')) ?>" <div class="group-option" data-group-id="<?= (int) $g['id'] ?>" data-name="<?= e($g['name_ar'] . ' ' . ($g['discipline_name'] ?? '')) ?>"
style="border:2px solid <?= (isset($selectedGroup) && (int)$selectedGroup['id'] === (int)$g['id']) ? '#2563EB' : '#E5E7EB' ?>;border-radius:10px;padding:14px;cursor:pointer;transition:border-color 0.2s;"> style="border:2px solid <?= (isset($selectedGroup) && (int)$selectedGroup['id'] === (int)$g['id']) ? '#2563EB' : '#E5E7EB' ?>;border-radius:12px;padding:16px;cursor:pointer;transition:all 0.2s;-webkit-tap-highlight-color:transparent;touch-action:manipulation;">
<div style="font-weight:600;font-size:14px;color:#1A1A2E;"><?= e($g['name_ar']) ?></div> <div style="display:flex;justify-content:space-between;align-items:flex-start;">
<div style="font-size:12px;color:#6B7280;margin-top:3px;"><?= e($g['discipline_name'] ?? '') ?><?= e($g['program_name'] ?? '') ?></div> <div style="flex:1;">
<div style="display:flex;justify-content:space-between;margin-top:8px;font-size:12px;"> <div style="font-weight:700;font-size:15px;color:#1A1A2E;"><?= e($g['name_ar']) ?></div>
<span style="color:#6B7280;">السعة: <?= (int) $g['current_count'] ?>/<?= (int) $g['max_capacity'] ?></span> <div style="font-size:13px;color:#6B7280;margin-top:4px;"><?= e($g['discipline_name'] ?? '') ?><?= e($g['program_name'] ?? '') ?></div>
<span style="color:#059669;font-weight:600;"> </div>
<?= $registration['player_type'] === 'member' ? money((float) $g['monthly_fee_member']) : money((float) $g['monthly_fee_nonmember']) ?> / شهر <div style="text-align:left;flex-shrink:0;padding-right:10px;">
</span> <div style="font-size:16px;font-weight:800;color:#059669;">
<?= number_format($registration['player_type'] === 'member' ? (float) $g['monthly_fee_member'] : (float) $g['monthly_fee_nonmember'], 0) ?>
</div>
<div style="font-size:11px;color:#6B7280;">ج.م / شهر</div>
</div>
</div>
<div style="margin-top:8px;display:flex;align-items:center;gap:8px;">
<div style="flex:1;height:6px;background:#E5E7EB;border-radius:3px;overflow:hidden;">
<div style="height:100%;background:<?= ((int) $g['current_count'] / max(1, (int) $g['max_capacity'])) > 0.8 ? '#F59E0B' : '#059669' ?>;width:<?= min(100, ((int) $g['current_count'] / max(1, (int) $g['max_capacity'])) * 100) ?>%;border-radius:3px;"></div>
</div>
<span style="font-size:11px;color:#6B7280;white-space:nowrap;"><?= (int) $g['current_count'] ?>/<?= (int) $g['max_capacity'] ?></span>
</div> </div>
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
...@@ -116,144 +166,161 @@ ...@@ -116,144 +166,161 @@
</div> </div>
<!-- Subscription Options --> <!-- Subscription Options -->
<div class="card" style="margin-bottom:20px;" id="subscriptionOptions"> <div class="card" style="margin-bottom:16px;" id="subscriptionOptions">
<div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;"> <div style="padding:14px 16px;border-bottom:1px solid #E5E7EB;">
<h3 style="margin:0;font-size:16px;font-weight:600;"><i data-lucide="settings-2" style="width:16px;height:16px;vertical-align:middle;margin-left:6px;"></i> خيارات الاشتراك</h3> <h3 style="margin:0;font-size:15px;font-weight:600;">مدة الاشتراك والخصومات</h3>
</div> </div>
<div style="padding:20px;"> <div style="padding:16px;">
<div style="display:flex;gap:15px;flex-wrap:wrap;margin-bottom:15px;"> <div style="display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:14px;">
<label style="display:flex;align-items:center;gap:8px;padding:12px 18px;border:2px solid #2563EB;border-radius:8px;cursor:pointer;background:#EFF6FF;"> <label style="display:flex;align-items:center;justify-content:center;gap:8px;padding:14px;border:2px solid #2563EB;border-radius:10px;cursor:pointer;background:#EFF6FF;min-height:50px;touch-action:manipulation;-webkit-tap-highlight-color:transparent;">
<input type="radio" name="subscription_months" value="1" checked style="accent-color:#2563EB;"> <input type="radio" name="subscription_months" value="1" checked style="accent-color:#2563EB;width:18px;height:18px;">
<span style="font-weight:600;">شهر واحد</span> <span style="font-weight:700;font-size:15px;">شهر</span>
</label>
<label style="display:flex;align-items:center;gap:8px;padding:12px 18px;border:2px solid #E5E7EB;border-radius:8px;cursor:pointer;position:relative;">
<input type="radio" name="subscription_months" value="3" style="accent-color:#059669;">
<span style="font-weight:600;">3 أشهر</span>
<span style="position:absolute;top:-8px;left:10px;background:#059669;color:#fff;font-size:10px;padding:2px 6px;border-radius:4px;font-weight:700;">خصم 15%</span>
</label> </label>
</div> <label style="display:flex;align-items:center;justify-content:center;gap:8px;padding:14px;border:2px solid #E5E7EB;border-radius:10px;cursor:pointer;position:relative;min-height:50px;touch-action:manipulation;-webkit-tap-highlight-color:transparent;">
<div style="margin-bottom:0;"> <input type="radio" name="subscription_months" value="3" style="accent-color:#059669;width:18px;height:18px;">
<label style="display:flex;align-items:center;gap:8px;cursor:pointer;"> <span style="font-weight:700;font-size:15px;">3 أشهر</span>
<input type="checkbox" id="hasSibling" style="accent-color:#7C3AED;width:18px;height:18px;"> <span style="position:absolute;top:-8px;left:50%;transform:translateX(-50%);background:#059669;color:#fff;font-size:10px;padding:2px 8px;border-radius:4px;font-weight:700;white-space:nowrap;">خصم 15%</span>
<span style="font-size:14px;">يوجد أخ/أخت مسجل بنفس النشاط <span style="font-size:11px;color:#7C3AED;font-weight:600;">(خصم أشقاء)</span></span>
</label> </label>
</div> </div>
<label style="display:flex;align-items:center;gap:10px;padding:14px;border:1px solid #E5E7EB;border-radius:10px;cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent;">
<input type="checkbox" id="hasSibling" style="accent-color:#7C3AED;width:20px;height:20px;">
<span style="font-size:14px;font-weight:500;">يوجد أخ/أخت مسجل بنفس النشاط</span>
<span style="font-size:11px;color:#7C3AED;font-weight:700;margin-right:auto;">خصم أشقاء</span>
</label>
</div> </div>
</div> </div>
<!-- Fee Breakdown --> <!-- Fee Breakdown -->
<div class="card" style="margin-bottom:20px;" id="feeBreakdown" style="<?= $selectedGroup ? '' : 'display:none;' ?>"> <div class="card" style="margin-bottom:16px;" id="feeBreakdown">
<div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;"> <div style="padding:16px;">
<h3 style="margin:0;font-size:16px;font-weight:600;">تفاصيل الرسوم</h3>
</div>
<div style="padding:20px;">
<table style="width:100%;font-size:14px;"> <table style="width:100%;font-size:14px;">
<tr><td style="padding:6px 0;">رسوم التسجيل</td><td style="text-align:left;font-weight:600;" id="feeReg"><?= money((float) $registration['registration_fee']) ?></td></tr> <tr><td style="padding:8px 0;">رسوم الكارت</td><td style="text-align:left;font-weight:600;" id="feeCard"><?= number_format((float) $registration['card_fee'], 0) ?> ج.م</td></tr>
<tr><td style="padding:6px 0;">رسوم الكارت</td><td style="text-align:left;font-weight:600;" id="feeCard"><?= money((float) $registration['card_fee']) ?></td></tr> <tr><td style="padding:8px 0;">رسوم الاستمارة</td><td style="text-align:left;font-weight:600;" id="feeForm"><?= number_format((float) $registration['form_fee'], 0) ?> ج.م</td></tr>
<tr><td style="padding:6px 0;">رسوم الاستمارة</td><td style="text-align:left;font-weight:600;" id="feeForm"><?= money((float) $registration['form_fee']) ?></td></tr> <tr><td style="padding:8px 0;">اشتراك النشاط</td><td style="text-align:left;font-weight:700;color:#059669;" id="feeSub"><?= number_format((float) ($registration['subscription_amount'] ?? 0), 0) ?> ج.م</td></tr>
<tr><td style="padding:6px 0;">اشتراك النشاط</td><td style="text-align:left;font-weight:600;" id="feeSub"><?= money((float) ($registration['subscription_amount'] ?? 0)) ?></td></tr> <tr id="feeDiscountRow" style="display:none;"><td style="padding:8px 0;color:#059669;">خصم</td><td style="text-align:left;font-weight:600;color:#059669;" id="feeDiscount"></td></tr>
<tr id="feeDiscountRow" style="display:none;color:#059669;"><td style="padding:6px 0;">خصم</td><td style="text-align:left;font-weight:600;" id="feeDiscount"></td></tr> <tr style="border-top:2px solid #E5E7EB;"><td style="padding:12px 0;font-weight:800;font-size:16px;">إجمالي الاشتراك</td><td style="text-align:left;font-weight:800;font-size:18px;color:#2563EB;" id="feeTotal"><?= number_format((float) $registration['subscription_amount'] + (float) $registration['card_fee'] + (float) $registration['form_fee'], 0) ?> ج.م</td></tr>
<tr style="border-top:2px solid #E5E7EB;"><td style="padding:10px 0;font-weight:700;font-size:15px;">الإجمالي</td><td style="text-align:left;font-weight:800;font-size:15px;color:#2563EB;" id="feeTotal"><?= money((float) $registration['total_fees']) ?></td></tr>
</table> </table>
<div id="discountNotes" style="display:none;margin-top:10px;padding:8px 12px;background:#ECFDF5;border-radius:6px;font-size:12px;color:#059669;"></div> <div id="discountNotes" style="display:none;margin-top:10px;padding:10px 14px;background:#ECFDF5;border-radius:8px;font-size:12px;color:#059669;"></div>
</div> </div>
</div> </div>
<div style="display:flex;gap:10px;"> <div style="display:grid;grid-template-columns:1fr auto;gap:10px;">
<button type="button" id="btnActivityNext" class="btn btn-primary" <?= $selectedGroup ? '' : 'disabled' ?>><i data-lucide="banknote" style="width:14px;height:14px;vertical-align:middle;margin-left:4px;"></i> إرسال للخزينة</button> <button type="button" id="btnActivityNext" class="btn btn-primary" style="padding:16px;font-size:16px;font-weight:700;border-radius:12px;min-height:56px;" <?= $selectedGroup ? '' : 'disabled' ?>>
<button type="button" class="btn btn-outline" onclick="showStep('photo')"><i data-lucide="arrow-right" style="width:14px;height:14px;vertical-align:middle;margin-left:4px;"></i> رجوع</button> <i data-lucide="banknote" style="width:18px;height:18px;vertical-align:middle;margin-left:6px;"></i> إرسال للخزينة
</button>
<button type="button" class="btn btn-outline" style="padding:16px;border-radius:12px;min-height:56px;" onclick="showStep('photo')">
<i data-lucide="arrow-right" style="width:18px;height:18px;"></i>
</button>
</div> </div>
</div> </div>
<!-- Step 4: Pending Payment --> <!-- Step 4: Pending Payment -->
<div id="step-payment" class="wizard-step" style="<?= ($step ?? 2) == 4 ? '' : 'display:none;' ?>"> <div id="step-payment" class="wizard-step" style="<?= ($step ?? 1) == 4 ? '' : 'display:none;' ?>">
<div class="card" style="margin-bottom:20px;"> <div class="card" style="margin-bottom:16px;">
<div style="padding:40px;text-align:center;"> <div style="padding:40px 24px;text-align:center;">
<div style="width:80px;height:80px;border-radius:50%;background:#FEF3C7;margin:0 auto 15px;display:flex;align-items:center;justify-content:center;"> <div style="width:80px;height:80px;border-radius:50%;background:#FEF3C7;margin:0 auto 16px;display:flex;align-items:center;justify-content:center;">
<i data-lucide="clock" style="width:40px;height:40px;color:#D97706;"></i> <i data-lucide="clock" style="width:40px;height:40px;color:#D97706;"></i>
</div> </div>
<h3 style="margin:0 0 8px;font-size:18px;font-weight:700;color:#1A1A2E;">بانتظار الدفع في الخزينة</h3> <h3 style="margin:0 0 8px;font-size:18px;font-weight:700;color:#1A1A2E;">بانتظار دفع الاشتراك</h3>
<p style="color:#6B7280;font-size:14px;margin:0;">تم إرسال طلب الدفع — ينتظر التحصيل من الخزينة</p> <p style="color:#6B7280;font-size:14px;margin:0;">تم إرسال طلب دفع الاشتراك — ينتظر التحصيل من الخزينة</p>
<div style="margin-top:15px;font-size:20px;font-weight:800;color:#2563EB;"><?= money((float) $registration['total_fees']) ?></div> <div style="margin-top:16px;font-size:24px;font-weight:800;color:#2563EB;"><?= number_format((float) $registration['subscription_amount'] + (float) $registration['card_fee'] + (float) $registration['form_fee'], 0) ?> ج.م</div>
</div> </div>
</div> </div>
<div style="display:flex;gap:10px;"> <div style="display:grid;grid-template-columns:1fr 1fr;gap:10px;">
<a href="/sa/registration/<?= (int) $registration['id'] ?>/print-form" target="_blank" class="btn btn-outline"><i data-lucide="printer" style="width:14px;height:14px;vertical-align:middle;margin-left:4px;"></i> طباعة الاستمارة</a> <a href="/sa/registration/<?= (int) $registration['id'] ?>/print-form" target="_blank" class="btn btn-outline" style="padding:14px;font-size:14px;border-radius:10px;min-height:50px;text-align:center;">
<form method="POST" action="/sa/registration/<?= (int) $registration['id'] ?>/cancel" style="display:inline;"> <i data-lucide="printer" style="width:16px;height:16px;vertical-align:middle;margin-left:4px;"></i> طباعة الاستمارة
</a>
<form method="POST" action="/sa/registration/<?= (int) $registration['id'] ?>/cancel" style="display:contents;">
<?= csrf_field() ?> <?= csrf_field() ?>
<button type="submit" class="btn btn-outline" style="color:#DC2626;border-color:#DC2626;" onclick="return confirm('هل تريد إلغاء التسجيل؟')">إلغاء التسجيل</button> <button type="submit" class="btn btn-outline" style="padding:14px;font-size:14px;border-radius:10px;min-height:50px;color:#DC2626;border-color:#DC2626;" onclick="return confirm('هل تريد إلغاء التسجيل؟')">
<i data-lucide="x" style="width:16px;height:16px;vertical-align:middle;margin-left:4px;"></i> إلغاء
</button>
</form> </form>
</div> </div>
</div> </div>
<!-- Step 5: Complete --> <!-- Step 5: Complete -->
<div id="step-complete" class="wizard-step" style="<?= ($step ?? 2) == 5 ? '' : 'display:none;' ?>"> <div id="step-complete" class="wizard-step" style="<?= ($step ?? 1) == 5 ? '' : 'display:none;' ?>">
<div class="card" style="margin-bottom:20px;"> <div class="card" style="margin-bottom:16px;">
<div style="padding:40px;text-align:center;"> <div style="padding:40px 24px;text-align:center;">
<div style="width:80px;height:80px;border-radius:50%;background:#ECFDF5;margin:0 auto 15px;display:flex;align-items:center;justify-content:center;"> <div style="width:80px;height:80px;border-radius:50%;background:#ECFDF5;margin:0 auto 16px;display:flex;align-items:center;justify-content:center;">
<i data-lucide="check-circle" style="width:40px;height:40px;color:#059669;"></i> <i data-lucide="check-circle" style="width:40px;height:40px;color:#059669;"></i>
</div> </div>
<h3 style="margin:0 0 8px;font-size:18px;font-weight:700;color:#059669;">تم التسجيل بنجاح!</h3> <h3 style="margin:0 0 8px;font-size:18px;font-weight:700;color:#059669;">تم التسجيل بنجاح!</h3>
<p style="color:#6B7280;font-size:14px;margin:0;">تم الدفع وتفعيل التسجيل</p> <p style="color:#6B7280;font-size:14px;margin:0;">تم الدفع وتفعيل الاشتراك</p>
</div> </div>
</div> </div>
<div style="display:flex;gap:10px;flex-wrap:wrap;"> <div style="display:grid;grid-template-columns:1fr 1fr;gap:10px;">
<a href="/sa/registration/<?= (int) $registration['id'] ?>/print-form" target="_blank" class="btn btn-outline"><i data-lucide="file-text" style="width:14px;height:14px;vertical-align:middle;margin-left:4px;"></i> طباعة الاستمارة</a> <a href="/sa/registration/<?= (int) $registration['id'] ?>/print-form" target="_blank" class="btn btn-outline" style="padding:14px;font-size:14px;border-radius:10px;min-height:50px;text-align:center;">
<button type="button" id="btnGenerateCard" class="btn btn-primary" <?= (int) $registration['card_generated'] ? 'disabled' : '' ?>><i data-lucide="credit-card" style="width:14px;height:14px;vertical-align:middle;margin-left:4px;"></i> إنشاء الكارت</button> <i data-lucide="file-text" style="width:16px;height:16px;vertical-align:middle;margin-left:4px;"></i> طباعة الاستمارة
<?php if ((int) $registration['card_generated']): ?> </a>
<a href="/sa/registration/<?= (int) $registration['id'] ?>/print-card" target="_blank" class="btn btn-outline"><i data-lucide="printer" style="width:14px;height:14px;vertical-align:middle;margin-left:4px;"></i> طباعة الكارت</a> <button type="button" id="btnGenerateCard" class="btn btn-primary" style="padding:14px;font-size:14px;border-radius:10px;min-height:50px;" <?= (int) $registration['card_generated'] ? 'disabled' : '' ?>>
<?php endif; ?> <i data-lucide="credit-card" style="width:16px;height:16px;vertical-align:middle;margin-left:4px;"></i> إنشاء الكارت
<a href="/sa/registration" class="btn btn-outline"><i data-lucide="plus" style="width:14px;height:14px;vertical-align:middle;margin-left:4px;"></i> تسجيل جديد</a> </button>
</div> </div>
<?php if ((int) $registration['card_generated']): ?>
<div style="margin-top:10px;display:grid;grid-template-columns:1fr 1fr;gap:10px;">
<a href="/sa/registration/<?= (int) $registration['id'] ?>/print-card" target="_blank" class="btn btn-outline" style="padding:14px;font-size:14px;border-radius:10px;min-height:50px;text-align:center;">
<i data-lucide="printer" style="width:16px;height:16px;vertical-align:middle;margin-left:4px;"></i> طباعة الكارت
</a>
<a href="/sa/registration" class="btn btn-outline" style="padding:14px;font-size:14px;border-radius:10px;min-height:50px;text-align:center;">
<i data-lucide="plus" style="width:16px;height:16px;vertical-align:middle;margin-left:4px;"></i> تسجيل جديد
</a>
</div>
<?php endif; ?>
</div> </div>
</div> </div>
<?php else: ?> <?php else: ?>
<!-- Start New Registration --> <!-- Start New Registration -->
<div class="card" style="margin-bottom:20px;"> <div class="card" style="margin-bottom:16px;">
<div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;"> <div style="padding:16px 20px;border-bottom:1px solid #E5E7EB;">
<h3 style="margin:0;font-size:16px;font-weight:600;"><i data-lucide="user-plus" style="width:18px;height:18px;vertical-align:middle;margin-left:6px;"></i> تسجيل جديد</h3> <h3 style="margin:0;font-size:16px;font-weight:600;"><i data-lucide="user-plus" style="width:18px;height:18px;vertical-align:middle;margin-left:6px;"></i> تسجيل جديد</h3>
</div> </div>
<div style="padding:20px;"> <div style="padding:20px;">
<form id="startForm"> <form id="startForm">
<div style="display:grid;grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));gap:15px;"> <div style="display:grid;grid-template-columns:1fr;gap:14px;">
<div> <div style="display:grid;grid-template-columns:1fr 1fr;gap:10px;">
<label class="form-label">نوع اللاعب <span style="color:#DC2626;">*</span></label> <div>
<select name="player_type" id="regPlayerType" class="form-select" required> <label class="form-label">نوع اللاعب</label>
<option value="non_member">غير عضو</option> <select name="player_type" id="regPlayerType" class="form-select" style="padding:14px;font-size:15px;border-radius:10px;" required>
<option value="member">عضو</option> <option value="non_member">غير عضو</option>
</select> <option value="member">عضو</option>
</div> </select>
<div id="memberIdWrap" style="display:none;"> </div>
<label class="form-label">رقم العضوية <span style="color:#DC2626;">*</span></label> <div id="memberIdWrap" style="display:none;">
<input type="number" name="member_id" class="form-input" placeholder="رقم العضوية"> <label class="form-label">رقم العضوية</label>
<input type="number" name="member_id" class="form-input" style="padding:14px;font-size:15px;border-radius:10px;" placeholder="رقم العضوية">
</div>
</div> </div>
<div> <div>
<label class="form-label">الرقم القومي <span style="color:#DC2626;">*</span></label> <label class="form-label">الرقم القومي <span style="color:#DC2626;">*</span></label>
<input type="text" name="national_id" class="form-input" maxlength="14" dir="ltr" placeholder="14 رقم" id="regNid"> <input type="text" name="national_id" class="form-input" style="padding:14px;font-size:18px;border-radius:10px;direction:ltr;text-align:right;letter-spacing:1px;" maxlength="14" inputmode="numeric" pattern="[0-9]*" placeholder="أدخل 14 رقم" id="regNid">
<small id="regNidInfo" style="display:none;margin-top:4px;font-size:11px;color:#059669;"></small> <small id="regNidInfo" style="display:none;margin-top:6px;font-size:12px;color:#059669;"></small>
</div> </div>
<div> <div>
<label class="form-label">الاسم بالعربي <span style="color:#DC2626;">*</span></label> <label class="form-label">الاسم بالعربي <span style="color:#DC2626;">*</span></label>
<input type="text" name="full_name_ar" class="form-input" id="regNameAr"> <input type="text" name="full_name_ar" class="form-input" style="padding:14px;font-size:15px;border-radius:10px;" id="regNameAr">
</div> </div>
<div> <div style="display:grid;grid-template-columns:1fr 1fr;gap:10px;">
<label class="form-label">الهاتف</label> <div>
<input type="text" name="phone" class="form-input" dir="ltr"> <label class="form-label">الهاتف</label>
<input type="text" name="phone" class="form-input" style="padding:14px;font-size:15px;border-radius:10px;" dir="ltr" inputmode="tel">
</div>
<div>
<label class="form-label">هاتف ولي الأمر</label>
<input type="text" name="guardian_phone" class="form-input" style="padding:14px;font-size:15px;border-radius:10px;" dir="ltr" inputmode="tel">
</div>
</div> </div>
<div> <div>
<label class="form-label">اسم ولي الأمر</label> <label class="form-label">اسم ولي الأمر</label>
<input type="text" name="guardian_name" class="form-input"> <input type="text" name="guardian_name" class="form-input" style="padding:14px;font-size:15px;border-radius:10px;">
</div> </div>
<div>
<label class="form-label">هاتف ولي الأمر</label>
<input type="text" name="guardian_phone" class="form-input" dir="ltr">
</div>
</div>
<div style="margin-top:20px;">
<button type="submit" class="btn btn-primary" id="btnStartReg"><i data-lucide="play" style="width:14px;height:14px;vertical-align:middle;margin-left:4px;"></i> بدء التسجيل</button>
</div> </div>
<div id="startError" style="display:none;margin-top:10px;padding:10px;background:#FEF2F2;border-radius:6px;color:#DC2626;font-size:13px;"></div> <button type="submit" class="btn btn-primary" id="btnStartReg" style="width:100%;margin-top:20px;padding:16px;font-size:16px;font-weight:700;border-radius:12px;min-height:56px;">
<i data-lucide="play" style="width:18px;height:18px;vertical-align:middle;margin-left:6px;"></i> بدء التسجيل
</button>
<div id="startError" style="display:none;margin-top:12px;padding:12px;background:#FEF2F2;border-radius:8px;color:#DC2626;font-size:13px;"></div>
</form> </form>
</div> </div>
</div> </div>
...@@ -261,37 +328,34 @@ ...@@ -261,37 +328,34 @@
<!-- Recent Registrations --> <!-- Recent Registrations -->
<?php if (!empty($recentRegistrations)): ?> <?php if (!empty($recentRegistrations)): ?>
<div class="card"> <div class="card">
<div style="padding:15px 20px;border-bottom:1px solid #E5E7EB;"> <div style="padding:14px 16px;border-bottom:1px solid #E5E7EB;">
<h3 style="margin:0;font-size:16px;font-weight:600;">آخر التسجيلات</h3> <h3 style="margin:0;font-size:15px;font-weight:600;">آخر التسجيلات</h3>
</div>
<div style="padding:0;">
<?php foreach ($recentRegistrations as $reg): ?>
<a href="/sa/registration/<?= (int) $reg['id'] ?>" style="display:flex;align-items:center;padding:14px 16px;border-bottom:1px solid #F3F4F6;text-decoration:none;color:inherit;touch-action:manipulation;-webkit-tap-highlight-color:rgba(37,99,235,0.1);">
<div style="width:40px;height:40px;border-radius:8px;overflow:hidden;background:#F3F4F6;flex-shrink:0;display:flex;align-items:center;justify-content:center;margin-left:12px;">
<?php if (!empty($reg['photo_path'])): ?>
<img src="/<?= e($reg['photo_path']) ?>" style="width:100%;height:100%;object-fit:cover;">
<?php else: ?>
<i data-lucide="user" style="width:18px;height:18px;color:#9CA3AF;"></i>
<?php endif; ?>
</div>
<div style="flex:1;min-width:0;">
<div style="font-weight:600;font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;"><?= e($reg['full_name_ar']) ?></div>
<div style="font-size:12px;color:#6B7280;margin-top:2px;"><?= e($reg['group_name'] ?? '—') ?></div>
</div>
<div style="text-align:left;flex-shrink:0;">
<?php
$statusMap = ['in_progress' => ['جاري', '#F59E0B'], 'pending_payment' => ['بانتظار', '#D97706'], 'completed' => ['مكتمل', '#059669'], 'cancelled' => ['ملغى', '#DC2626']];
$s = $statusMap[$reg['status']] ?? [$reg['status'], '#6B7280'];
?>
<span style="padding:3px 8px;border-radius:6px;font-size:11px;font-weight:600;background:<?= $s[1] ?>15;color:<?= $s[1] ?>;"><?= $s[0] ?></span>
<div style="font-size:10px;color:#9CA3AF;margin-top:3px;direction:ltr;"><?= substr($reg['created_at'], 5, 11) ?></div>
</div>
</a>
<?php endforeach; ?>
</div> </div>
<table style="width:100%;border-collapse:collapse;font-size:13px;">
<thead>
<tr style="background:#F9FAFB;">
<th style="padding:10px 15px;text-align:right;font-weight:600;color:#6B7280;">الرقم</th>
<th style="padding:10px 15px;text-align:right;font-weight:600;color:#6B7280;">اللاعب</th>
<th style="padding:10px 15px;text-align:right;font-weight:600;color:#6B7280;">النشاط</th>
<th style="padding:10px 15px;text-align:right;font-weight:600;color:#6B7280;">الحالة</th>
<th style="padding:10px 15px;text-align:right;font-weight:600;color:#6B7280;">التاريخ</th>
</tr>
</thead>
<tbody>
<?php foreach ($recentRegistrations as $reg): ?>
<tr style="border-top:1px solid #F3F4F6;">
<td style="padding:10px 15px;"><a href="/sa/registration/<?= (int) $reg['id'] ?>" style="color:#2563EB;font-weight:600;"><?= e($reg['registration_number']) ?></a></td>
<td style="padding:10px 15px;"><?= e($reg['full_name_ar']) ?></td>
<td style="padding:10px 15px;"><?= e($reg['group_name'] ?? '—') ?></td>
<td style="padding:10px 15px;">
<?php
$statusMap = ['in_progress' => ['جاري', '#F59E0B'], 'pending_payment' => ['بانتظار الدفع', '#D97706'], 'completed' => ['مكتمل', '#059669'], 'cancelled' => ['ملغى', '#DC2626']];
$s = $statusMap[$reg['status']] ?? [$reg['status'], '#6B7280'];
?>
<span style="padding:3px 8px;border-radius:4px;font-size:11px;font-weight:600;background:<?= $s[1] ?>15;color:<?= $s[1] ?>;"><?= $s[0] ?></span>
</td>
<td style="padding:10px 15px;direction:ltr;text-align:right;"><?= substr($reg['created_at'], 0, 16) ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php endif; ?> <?php endif; ?>
...@@ -327,6 +391,7 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -327,6 +391,7 @@ document.addEventListener('DOMContentLoaded', function() {
}).then(function(r){return r.json();}).then(function(data) { }).then(function(r){return r.json();}).then(function(data) {
if (data.parsed && data.parsed.is_valid) { if (data.parsed && data.parsed.is_valid) {
regNidInfo.style.display = 'block'; regNidInfo.style.display = 'block';
regNidInfo.style.color = '#059669';
regNidInfo.textContent = '✓ ' + data.parsed.governorate_name_ar + ' — ' + data.parsed.age_years + ' سنة — ' + (data.parsed.gender === 'male' ? 'ذكر' : 'أنثى'); regNidInfo.textContent = '✓ ' + data.parsed.governorate_name_ar + ' — ' + data.parsed.age_years + ' سنة — ' + (data.parsed.gender === 'male' ? 'ذكر' : 'أنثى');
} else { } else {
regNidInfo.style.display = 'block'; regNidInfo.style.display = 'block';
...@@ -336,7 +401,6 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -336,7 +401,6 @@ document.addEventListener('DOMContentLoaded', function() {
}); });
} else { } else {
regNidInfo.style.display = 'none'; regNidInfo.style.display = 'none';
regNidInfo.style.color = '#059669';
} }
}); });
} }
...@@ -377,7 +441,29 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -377,7 +441,29 @@ document.addEventListener('DOMContentLoaded', function() {
} }
window.showStep = showStep; window.showStep = showStep;
// Photo: webcam // Step 1: Pay form fee
var btnPayForm = document.getElementById('btnPayForm');
if (btnPayForm) {
btnPayForm.addEventListener('click', function() {
this.disabled = true;
this.textContent = 'جاري الإرسال...';
fetch('/sa/registration/' + regId + '/pay-form', {
method: 'POST',
headers: {'Content-Type':'application/json','X-Requested-With':'XMLHttpRequest','X-CSRF-TOKEN': csrfToken},
body: JSON.stringify({_csrf_token: csrfToken})
}).then(function(r){return r.json();}).then(function(data) {
if (data.success) {
window.location.reload();
} else {
alert(data.error || 'حدث خطأ');
btnPayForm.disabled = false;
btnPayForm.textContent = 'إرسال للخزينة';
}
});
});
}
// Step 2: Photo
var video = document.getElementById('webcamVideo'); var video = document.getElementById('webcamVideo');
var canvas = document.getElementById('webcamCanvas'); var canvas = document.getElementById('webcamCanvas');
var btnStart = document.getElementById('btnStartWebcam'); var btnStart = document.getElementById('btnStartWebcam');
...@@ -416,7 +502,6 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -416,7 +502,6 @@ document.addEventListener('DOMContentLoaded', function() {
}); });
} }
// Photo: file upload
var fileInput = document.getElementById('photoFileInput'); var fileInput = document.getElementById('photoFileInput');
if (fileInput) { if (fileInput) {
fileInput.addEventListener('change', function() { fileInput.addEventListener('change', function() {
...@@ -435,7 +520,6 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -435,7 +520,6 @@ document.addEventListener('DOMContentLoaded', function() {
photoStatus.style.display = 'block'; photoStatus.style.display = 'block';
photoStatus.style.color = '#6B7280'; photoStatus.style.color = '#6B7280';
photoStatus.textContent = 'جاري رفع الصورة...'; photoStatus.textContent = 'جاري رفع الصورة...';
fetch('/sa/registration/' + regId + '/photo', { fetch('/sa/registration/' + regId + '/photo', {
method: 'POST', method: 'POST',
headers: {'Content-Type':'application/json','X-Requested-With':'XMLHttpRequest','X-CSRF-TOKEN': csrfToken}, headers: {'Content-Type':'application/json','X-Requested-With':'XMLHttpRequest','X-CSRF-TOKEN': csrfToken},
...@@ -456,7 +540,7 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -456,7 +540,7 @@ document.addEventListener('DOMContentLoaded', function() {
btnPhotoNext.addEventListener('click', function() { showStep('activity'); }); btnPhotoNext.addEventListener('click', function() { showStep('activity'); });
} }
// Activity selection // Step 3: Activity selection
var selectedGroupId = null; var selectedGroupId = null;
function getSubscriptionMonths() { function getSubscriptionMonths() {
...@@ -474,8 +558,11 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -474,8 +558,11 @@ document.addEventListener('DOMContentLoaded', function() {
body: JSON.stringify({group_id: gid, months: months, has_sibling: hasSibling, _csrf_token: csrfToken}) body: JSON.stringify({group_id: gid, months: months, has_sibling: hasSibling, _csrf_token: csrfToken})
}).then(function(r){return r.json();}).then(function(data) { }).then(function(r){return r.json();}).then(function(data) {
if (data.success) { if (data.success) {
document.getElementById('feeSub').textContent = data.subscription_amount.toLocaleString() + ' ج.م'; var sub = data.subscription_amount || 0;
document.getElementById('feeTotal').textContent = data.total_fees.toLocaleString() + ' ج.م'; var card = <?= (int) $registration['card_fee'] ?>;
var form = <?= (int) $registration['form_fee'] ?>;
document.getElementById('feeSub').textContent = Number(sub).toLocaleString() + ' ج.م';
document.getElementById('feeTotal').textContent = Number(sub + card + form).toLocaleString() + ' ج.م';
document.getElementById('feeBreakdown').style.display = ''; document.getElementById('feeBreakdown').style.display = '';
document.getElementById('btnActivityNext').disabled = false; document.getElementById('btnActivityNext').disabled = false;
...@@ -499,14 +586,17 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -499,14 +586,17 @@ document.addEventListener('DOMContentLoaded', function() {
document.querySelectorAll('.group-option').forEach(function(el) { document.querySelectorAll('.group-option').forEach(function(el) {
el.addEventListener('click', function() { el.addEventListener('click', function() {
document.querySelectorAll('.group-option').forEach(function(g) { g.style.borderColor = '#E5E7EB'; }); document.querySelectorAll('.group-option').forEach(function(g) {
g.style.borderColor = '#E5E7EB';
g.style.background = '';
});
this.style.borderColor = '#2563EB'; this.style.borderColor = '#2563EB';
this.style.background = '#F0F7FF';
selectedGroupId = this.dataset.groupId; selectedGroupId = this.dataset.groupId;
submitActivitySelection(selectedGroupId); submitActivitySelection(selectedGroupId);
}); });
}); });
// Re-calculate on months/sibling change
document.querySelectorAll('input[name="subscription_months"]').forEach(function(radio) { document.querySelectorAll('input[name="subscription_months"]').forEach(function(radio) {
radio.addEventListener('change', function() { radio.addEventListener('change', function() {
document.querySelectorAll('input[name="subscription_months"]').forEach(function(r) { document.querySelectorAll('input[name="subscription_months"]').forEach(function(r) {
...@@ -518,9 +608,13 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -518,9 +608,13 @@ document.addEventListener('DOMContentLoaded', function() {
if (selectedGroupId) submitActivitySelection(selectedGroupId); if (selectedGroupId) submitActivitySelection(selectedGroupId);
}); });
}); });
document.getElementById('hasSibling').addEventListener('change', function() {
if (selectedGroupId) submitActivitySelection(selectedGroupId); var siblingCheckbox = document.getElementById('hasSibling');
}); if (siblingCheckbox) {
siblingCheckbox.addEventListener('change', function() {
if (selectedGroupId) submitActivitySelection(selectedGroupId);
});
}
// Group search // Group search
var groupSearch = document.getElementById('groupSearch'); var groupSearch = document.getElementById('groupSearch');
...@@ -533,7 +627,7 @@ document.addEventListener('DOMContentLoaded', function() { ...@@ -533,7 +627,7 @@ document.addEventListener('DOMContentLoaded', function() {
}); });
} }
// Submit to payment // Submit subscription to payment
var btnActivityNext = document.getElementById('btnActivityNext'); var btnActivityNext = document.getElementById('btnActivityNext');
if (btnActivityNext) { if (btnActivityNext) {
btnActivityNext.addEventListener('click', function() { btnActivityNext.addEventListener('click', function() {
......
...@@ -99,6 +99,18 @@ PermissionRegistry::register('sports_activity', [ ...@@ -99,6 +99,18 @@ PermissionRegistry::register('sports_activity', [
EventBus::listen('payment_request.completed', function (array $data): void { EventBus::listen('payment_request.completed', function (array $data): void {
$entityType = $data['related_entity_type'] ?? ''; $entityType = $data['related_entity_type'] ?? '';
try { try {
if ($entityType === 'sa_registration_form') {
$registrationId = (int) ($data['related_entity_id'] ?? 0);
if ($registrationId > 0) {
$db = App::getInstance()->db();
$db->update('sa_registrations', [
'form_payment_status' => 'paid',
'updated_at' => date('Y-m-d H:i:s'),
], 'id = ?', [$registrationId]);
}
return;
}
if ($entityType === 'sa_registrations') { if ($entityType === 'sa_registrations') {
$registrationId = (int) ($data['related_entity_id'] ?? 0); $registrationId = (int) ($data['related_entity_id'] ?? 0);
$paymentId = (int) ($data['payment_id'] ?? 0); $paymentId = (int) ($data['payment_id'] ?? 0);
......
<?php
declare(strict_types=1);
return [
'up' => "
ALTER TABLE `sa_registrations`
ADD COLUMN `form_payment_status` VARCHAR(20) NOT NULL DEFAULT 'unpaid' COMMENT 'unpaid, pending, paid' AFTER `payment_status`,
ADD COLUMN `form_payment_request_id` BIGINT UNSIGNED NULL AFTER `payment_request_id`;
",
'down' => "
ALTER TABLE `sa_registrations`
DROP COLUMN `form_payment_status`,
DROP COLUMN `form_payment_request_id`;
"
];
<?php
declare(strict_types=1);
return [
'up' => "ALTER TABLE `sa_registrations` ADD COLUMN `subscription_months` INT UNSIGNED NOT NULL DEFAULT 1 AFTER `subscription_amount`;",
'down' => "ALTER TABLE `sa_registrations` DROP COLUMN `subscription_months`;"
];
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