Enhance Activities Organised Page with Filters, Column Selector, and Download Functionality
- Updated the page title icon color for better visibility. - Added filter controls for Department, Category, and Date Range. - Implemented a column selector for customizable table views. - Integrated reusable components for sending emails and downloading proofs. - Enhanced DataTable initialization with dynamic filtering based on user selections. - Added functionality for selecting/deselecting all rows and managing download button state. - Implemented toast notifications for user feedback on actions. - Improved styling for checkboxes and dropdown menus for better user experience.
This commit is contained in:
@@ -115,7 +115,7 @@ class ActivitiesOrganisedController extends Controller
|
||||
return response()->json(['success' => 'Record deleted successfully']);
|
||||
}
|
||||
|
||||
public function getActivitiesOrganisedResponses()
|
||||
public function getActivitiesOrganisedResponses(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$isAdmin = $user->role->name === 'Admin';
|
||||
@@ -137,6 +137,25 @@ class ActivitiesOrganisedController extends Controller
|
||||
->where('faculty_id', $user->id);
|
||||
}
|
||||
|
||||
// Apply filters
|
||||
if ($request->has('department') && !empty($request->department)) {
|
||||
$responses->whereHas('department', function ($query) use ($request) {
|
||||
$query->where('id', $request->department);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->has('category') && !empty($request->category)) {
|
||||
$responses->where('category', $request->category);
|
||||
}
|
||||
|
||||
if ($request->has('dateFrom') && !empty($request->dateFrom)) {
|
||||
$responses->where('start_date', '>=', $request->dateFrom);
|
||||
}
|
||||
|
||||
if ($request->has('dateTo') && !empty($request->dateTo)) {
|
||||
$responses->where('end_date', '<=', $request->dateTo);
|
||||
}
|
||||
|
||||
return DataTables::of($responses)
|
||||
->addColumn('user_name', function ($response) {
|
||||
return $response->user->name ?? 'Unknown';
|
||||
@@ -161,9 +180,9 @@ class ActivitiesOrganisedController extends Controller
|
||||
|
||||
// View proof button for everyone
|
||||
if ($response->proof) {
|
||||
$actions[] = '<a href="' . asset('storage/' . $response->proof) . '" target="_blank" class="btn btn-sm btn-primary mr-1">View</a>';
|
||||
$actions[] = '<a href="' . asset('storage/' . $response->proof) . '" target="_blank" class="btn btn-sm btn-primary mr-1"><i class="fas fa-eye"></i></a>';
|
||||
} else {
|
||||
$actions[] = 'No Proof';
|
||||
$actions[] = '<span class="text-muted"><i class="fas fa-times-circle"></i></span>';
|
||||
}
|
||||
|
||||
// Edit button with role-appropriate route
|
||||
@@ -177,10 +196,10 @@ class ActivitiesOrganisedController extends Controller
|
||||
$editRoute = route('faculty.ActivitiesOrganised.edit', $response->id);
|
||||
}
|
||||
|
||||
$actions[] = '<a href="' . $editRoute . '" class="btn btn-sm btn-info mx-1">Edit</a>';
|
||||
$actions[] = '<a href="' . $editRoute . '" class="btn btn-sm btn-info mx-1"><i class="fas fa-edit"></i></a>';
|
||||
|
||||
$deleteRoute = route('activitiesOrganised.destroy', $response->id);
|
||||
$actions[] = '<button type="button" class="btn btn-sm btn-danger delete-btn" data-id="' . $response->id . '" data-url="' . $deleteRoute . '">Delete</button>';
|
||||
$actions[] = '<button type="button" class="btn btn-sm btn-danger delete-btn" data-id="' . $response->id . '" data-url="' . $deleteRoute . '"><i class="fas fa-trash"></i></button>';
|
||||
|
||||
return implode(' ', $actions);
|
||||
})
|
||||
|
||||
@@ -44,31 +44,38 @@ class AdminController extends Controller
|
||||
}
|
||||
public function viewActivitiesOrganisedResponses()
|
||||
{
|
||||
return view('pages.activities-organised.index');
|
||||
$departments = Department::all();
|
||||
return view('pages.activities-organised.index', compact('departments'));
|
||||
}
|
||||
public function viewIvOrganisedResponses()
|
||||
{
|
||||
return view('pages.iv-organised.index');
|
||||
$departments = Department::all();
|
||||
return view('pages.iv-organised.index', compact('departments'));
|
||||
}
|
||||
public function viewPublicationsResponses()
|
||||
{
|
||||
return view('pages.publications.index');
|
||||
$departments = Department::all();
|
||||
return view('pages.publications.index', compact('departments'));
|
||||
}
|
||||
public function viewBooksPublishedResponses()
|
||||
{
|
||||
return view('pages.booksPublished.index');
|
||||
$departments = Department::all();
|
||||
return view('pages.booksPublished.index', compact('departments'));
|
||||
}
|
||||
public function viewExternalEngagementResponses()
|
||||
{
|
||||
return view('pages.externalEngagement.index');
|
||||
$departments = Department::all();
|
||||
return view('pages.externalEngagement.index', compact('departments'));
|
||||
}
|
||||
public function viewOnlineCoursesResponses()
|
||||
{
|
||||
return view('pages.onlineCourses.index');
|
||||
$departments = Department::all();
|
||||
return view('pages.onlineCourses.index', compact('departments'));
|
||||
}
|
||||
public function viewPatentsResponses()
|
||||
{
|
||||
return view('pages.patents.index');
|
||||
$departments = Department::all();
|
||||
return view('pages.patents.index', compact('departments'));
|
||||
}
|
||||
|
||||
public function downloadProofs(Request $request, ProofDownloadService $proofDownloadService)
|
||||
|
||||
Reference in New Issue
Block a user