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 @@
Manage your club membership payments, subscriptions, and billing history
+| Invoice # | Student | -Club | Amount | Status | Due Date | @@ -47,94 +50,36 @@ @foreach($invoices as $invoice)|||
|---|---|---|---|---|---|---|---|---|
| {{ $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 === 'pending') + Pay Now + @else + Receipt + @endif |
There are no bills matching your criteria.
+ +You don't have any invoices yet.
Manage and view your family members
+Comprehensive member information and analytics