Feat: Activities Controller totally independent
This commit is contained in:
@@ -20,7 +20,7 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form action="{{ route('admin.ActivitiesAttended.update', $response->id) }}" method="POST" enctype="multipart/form-data">
|
||||
<form action="{{ request()->is('admin/*') ? route('admin.ActivitiesAttended.update', $response->id) : (request()->is('coordinator/*') ? route('coordinator.ActivitiesAttended.update', $response->id) : route('faculty.ActivitiesAttended.update', $response->id)) }}" method="POST" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
|
||||
@@ -145,7 +145,8 @@
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex items-center justify-end">
|
||||
<a href="{{ route('admin.ActivitiesAttendedResponses') }}" class="bg-gray-200 py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 mr-3">
|
||||
|
||||
<a href="{{ request()->is('admin/*') ? route('admin.ActivitiesAttendedResponses') : (request()->is('coordinator/*') ? route('coordinator.ActivitiesAttendedResponses') : route('faculty.ActivitiesAttendedResponses')) }}" class="bg-gray-200 py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500 mr-3">
|
||||
Cancel
|
||||
</a>
|
||||
<button type="submit" class="inline-flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-black">
|
||||
@@ -235,13 +235,15 @@
|
||||
// order: [[4, 'asc']],
|
||||
});
|
||||
};
|
||||
// Add this after your datatable initialization
|
||||
// Replace this event handler in your script
|
||||
$('#responses-table').on('click', '.delete-btn', function() {
|
||||
console.log("hsjda");
|
||||
if (confirm('Are you sure you want to delete this record?')) {
|
||||
const id = $(this).data('id');
|
||||
const url = $(this).data('url'); // Use the data-url attribute instead of hardcoded path
|
||||
|
||||
$.ajax({
|
||||
url: `/admin/activities-attended/${id}`,
|
||||
url: url, // This will use the correct URL based on user role
|
||||
type: 'DELETE',
|
||||
data: {
|
||||
"_token": "{{ csrf_token() }}"
|
||||
@@ -272,7 +274,18 @@
|
||||
};
|
||||
}
|
||||
|
||||
initAjaxRoute("{{ route('admin.ActivitiesAttendedResponses.data') }}");
|
||||
// Add this before initAjaxRoute call at the end of your script
|
||||
const userRole = "{{ auth()->user()->role->name }}";
|
||||
let dataRoute = "{{ route('admin.ActivitiesAttendedResponses.data') }}";
|
||||
|
||||
if (userRole === 'Coordinator') {
|
||||
dataRoute = "{{ route('coordinator.ActivitiesAttendedResponses.data') }}";
|
||||
}
|
||||
if (userRole === 'Faculty') {
|
||||
dataRoute = "{{ route('faculty.ActivitiesAttendedResponses.data') }}";
|
||||
}
|
||||
|
||||
initAjaxRoute(dataRoute);
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user