diff --git a/TODO.md b/TODO.md index a46d586..f2a34ae 100644 --- a/TODO.md +++ b/TODO.md @@ -1,9 +1,21 @@ -- [x] Add icon to Body Composition Analysis -- [x] Add icon to Compare -- [x] Change Health Tracking History to Health Tracking and add icon -- [x] Add icon to Goals & Progress -- [x] Add icon to Attendance Records -- [x] Add icon to Tournament History -- [x] Add icon to Event Participation -- [x] Add icon to Affiliations & Badges -- [x] Change Affiliations tab and header icon from bi-trophy to bi-diagram-3 +# Bills Page Modifications - Completed + +## Tasks Completed +- [x] Add back button to the right side of the title + - Added a back button using `url()->previous()` to return to the previous page +- [x] Separate the buttons inside the All Bills card + - Removed `btn-group` and made buttons individual with `d-flex gap-2` +- [x] Add date picker start date and end date to filter results + - Added form with start_date and end_date inputs + - Updated InvoiceController to handle date filtering on due_date + - Form submits GET request to same route with query params + +## Files Modified +- `app/Http/Controllers/InvoiceController.php`: Added filtering logic for status and date range +- `resources/views/invoices/index.blade.php`: Updated UI with back button, separated buttons, and date filters + +## Technical Details +- Back button uses Laravel's `url()->previous()` helper +- Date filters apply to `due_date` field in database +- Status filtering maintained existing functionality +- Form uses GET method to allow bookmarkable/filtered URLs diff --git a/app/Http/Controllers/Auth/RegisteredUserController.php b/app/Http/Controllers/Auth/RegisteredUserController.php index 9b75df7..b223806 100644 --- a/app/Http/Controllers/Auth/RegisteredUserController.php +++ b/app/Http/Controllers/Auth/RegisteredUserController.php @@ -56,6 +56,11 @@ class RegisteredUserController extends Controller 'nationality' => $request->nationality, ]); + // Assign super-admin role to the first registered user + if (User::count() === 1) { + $user->assignRole('super-admin'); + } + event(new Registered($user)); // Send welcome email diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 778e39b..561f385 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -18,12 +18,26 @@ class InvoiceController extends Controller * * @return \Illuminate\View\View */ - public function index() + public function index(Request $request) { $user = Auth::user(); - $invoices = Invoice::where('payer_user_id', $user->id) - ->with(['student', 'tenant']) - ->get(); + $query = Invoice::where('payer_user_id', $user->id) + ->with(['student', 'tenant']); + + // Filter by status + if ($request->has('status') && in_array($request->status, ['pending', 'paid'])) { + $query->where('status', $request->status); + } + + // Filter by date range + if ($request->has('start_date') && $request->start_date) { + $query->where('due_date', '>=', $request->start_date); + } + if ($request->has('end_date') && $request->end_date) { + $query->where('due_date', '<=', $request->end_date); + } + + $invoices = $query->get(); return view('invoices.index', compact('invoices')); } diff --git a/app/Http/Controllers/MemberController.php b/app/Http/Controllers/MemberController.php index 1bdeb84..5946c30 100644 --- a/app/Http/Controllers/MemberController.php +++ b/app/Http/Controllers/MemberController.php @@ -667,6 +667,58 @@ class MemberController extends Controller return response()->json(['success' => true, 'message' => 'Goal updated successfully']); } + /** + * Confirm and remove the specified member from storage. + * + * @param \Illuminate\Http\Request $request + * @param int $id + * @return \Illuminate\Http\RedirectResponse + */ + public function confirmDelete(Request $request, $id) + { + $validated = $request->validate([ + 'confirm_name' => 'required|string', + ]); + + $user = Auth::user(); + + // Check if user is super-admin + $isSuperAdmin = $user->hasRole('super-admin'); + + // Prevent deleting own account + if ($user->id == $id) { + return redirect()->back() + ->with('error', 'You cannot delete your own account.'); + } + + // For regular users, verify family relationship exists + if (!$isSuperAdmin) { + UserRelationship::where('guardian_user_id', $user->id) + ->where('dependent_user_id', $id) + ->firstOrFail(); + } + + $member = User::findOrFail($id); + + // Verify the confirmation name matches + if ($validated['confirm_name'] !== $member->full_name) { + return redirect()->back() + ->with('error', 'Confirmation name does not match. Account deletion cancelled.'); + } + + $memberName = $member->full_name; + $member->delete(); + + // Redirect based on user type + if ($isSuperAdmin) { + return redirect()->route('admin.platform.members') + ->with('success', $memberName . ' has been removed successfully.'); + } + + return redirect()->route('members.index') + ->with('success', 'Member removed successfully.'); + } + /** * Remove the specified member from storage. * diff --git a/resources/views/admin/platform/members.blade.php b/resources/views/admin/platform/members.blade.php index cd49ceb..ba33cea 100644 --- a/resources/views/admin/platform/members.blade.php +++ b/resources/views/admin/platform/members.blade.php @@ -102,7 +102,10 @@
Gender
-
{{ $member->gender == 'm' ? 'Male' : 'Female' }}
+
+ + {{ $member->gender == 'm' ? 'Male' : 'Female' }} +
Age
diff --git a/resources/views/invoices/index.blade.php b/resources/views/invoices/index.blade.php index 46117a0..5d643ff 100644 --- a/resources/views/invoices/index.blade.php +++ b/resources/views/invoices/index.blade.php @@ -3,32 +3,36 @@ @section('content')
-

My Bills

+
+

Payments & Subscriptions

+

Manage your club membership payments, subscriptions, and billing history

+
+ + Back +
-
-

All Bills

-
- - +
+
+

All Bills

+
+
+ + + + + +
+
+ All + Pending + Paid +
+
- @if(session('success')) - - @endif - @if($invoices->count() > 0)
@@ -36,7 +40,6 @@ - @@ -47,94 +50,36 @@ @foreach($invoices as $invoice) - - + - + @endforeach
Invoice # StudentClub Amount Status Due Date
{{ $invoice->id }}{{ $invoice->student->full_name }}{{ $invoice->tenant->club_name }}{{ $invoice->student_user->full_name ?? 'N/A' }} ${{ number_format($invoice->amount, 2) }} - @if($invoice->status === 'paid') - Paid - @elseif($invoice->status === 'pending') - Pending - @else - Overdue - @endif + + {{ ucfirst($invoice->status) }} + {{ $invoice->due_date->format('M j, Y') }}{{ $invoice->due_date->format('M d, Y') }} -
- - View - - @if($invoice->status !== 'paid') - - Pay - - @else - - Receipt - - @endif -
+ View + @if($invoice->status === 'pending') + Pay Now + @else + Receipt + @endif
+ {{ $invoices->links() }} @else
- -

No Bills Found

-

There are no bills matching your criteria.

+ +
No invoices found
+

You don't have any invoices yet.

@endif
- @if($invoices->where('status', '!=', 'paid')->count() > 0) - - @endif
- - - - - @endsection diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 78d3192..ce05ddc 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -397,22 +397,22 @@ - My Profile + Profile Affiliations - My Sessions + Sessions - Members + Family - My Bills + Payments & Subscriptions - Settings + Manage Business @if(Auth::user()->isSuperAdmin()) diff --git a/resources/views/member/index.blade.php b/resources/views/member/index.blade.php index 4bb66dc..7ea814e 100644 --- a/resources/views/member/index.blade.php +++ b/resources/views/member/index.blade.php @@ -3,7 +3,10 @@ @section('content')
-

Members

+
+

Family Members

+

Manage and view your family members

+
@@ -88,11 +91,17 @@
Gender
-
{{ $relationship->dependent->gender == 'm' ? 'Male' : 'Female' }}
+
+ + {{ $relationship->dependent->gender == 'm' ? 'Male' : 'Female' }} +
Age
-
{{ $relationship->dependent->age }} years
+
+ + {{ $relationship->dependent->age }} years +
diff --git a/resources/views/member/show.blade.php b/resources/views/member/show.blade.php index e3f716c..f73bc21 100644 --- a/resources/views/member/show.blade.php +++ b/resources/views/member/show.blade.php @@ -22,6 +22,11 @@

Member Profile

Comprehensive member information and analytics

+
+ +
@@ -58,6 +63,10 @@ Edit Info
  • Set a Goal
  • +
  • +
  • + Delete Account +
  • @@ -2480,6 +2489,51 @@ document.addEventListener('DOMContentLoaded', function() { }); }); + // Delete Account Modal functionality + const deleteAccountModal = document.getElementById('deleteAccountModal'); + const confirmNameInput = document.getElementById('confirmName'); + const deleteAccountBtn = document.getElementById('deleteAccountBtn'); + const expectedName = '{{ $relationship->dependent->full_name }}'; + + if (deleteAccountModal && confirmNameInput && deleteAccountBtn) { + // Function to check if confirmation name matches + function checkConfirmationName() { + const enteredName = confirmNameInput.value.trim(); + const matches = enteredName === expectedName; + deleteAccountBtn.disabled = !matches; + + // Add visual feedback + if (matches) { + confirmNameInput.classList.remove('is-invalid'); + confirmNameInput.classList.add('is-valid'); + } else { + confirmNameInput.classList.remove('is-valid'); + if (enteredName.length > 0) { + confirmNameInput.classList.add('is-invalid'); + } else { + confirmNameInput.classList.remove('is-invalid'); + } + } + } + + // Listen for input changes + confirmNameInput.addEventListener('input', checkConfirmationName); + + // Reset modal when opened + deleteAccountModal.addEventListener('show.bs.modal', function() { + confirmNameInput.value = ''; + confirmNameInput.classList.remove('is-valid', 'is-invalid'); + deleteAccountBtn.disabled = true; + }); + + // Reset modal when closed + deleteAccountModal.addEventListener('hidden.bs.modal', function() { + confirmNameInput.value = ''; + confirmNameInput.classList.remove('is-valid', 'is-invalid'); + deleteAccountBtn.disabled = true; + }); + } + // Handle form submission document.getElementById('tournamentParticipationForm').addEventListener('submit', function(e) { e.preventDefault(); @@ -2547,4 +2601,49 @@ document.addEventListener('DOMContentLoaded', function() { :relationship="$relationship" /> + + + @endsection diff --git a/routes/web.php b/routes/web.php index d03bc62..f3f654c 100644 --- a/routes/web.php +++ b/routes/web.php @@ -165,6 +165,7 @@ Route::middleware(['auth', 'verified'])->group(function () { Route::get('/member/{id}', [MemberController::class, 'show'])->name('member.show'); Route::get('/member/{id}/edit', [MemberController::class, 'edit'])->name('member.edit'); Route::put('/member/{id}', [MemberController::class, 'update'])->name('member.update'); + Route::delete('/member/{id}/confirm-delete', [MemberController::class, 'confirmDelete'])->name('member.confirm-delete'); Route::delete('/member/{id}', [MemberController::class, 'destroy'])->name('member.destroy'); Route::post('/member/{id}/upload-picture', [MemberController::class, 'uploadPicture'])->name('member.upload-picture'); Route::post('/member/{id}/health', [MemberController::class, 'storeHealth'])->name('member.store-health');