Feat: Iv organised
This commit is contained in:
@@ -26,5 +26,9 @@ class AdminController extends Controller
|
|||||||
{
|
{
|
||||||
return view('activities-organised.index');
|
return view('activities-organised.index');
|
||||||
}
|
}
|
||||||
|
public function viewIvOrganisedResponses()
|
||||||
|
{
|
||||||
|
return view('iv-organised.index');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,4 +26,9 @@ class CoordinatorController extends Controller
|
|||||||
return view('activities-organised.index');
|
return view('activities-organised.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function viewIvOrganisedResponses()
|
||||||
|
{
|
||||||
|
return view('iv-organised.index');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
|||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\ActivitiesAttended;
|
use App\Models\ActivitiesAttended;
|
||||||
use App\Models\ActivitiesOrganised;
|
use App\Models\ActivitiesOrganised;
|
||||||
|
use App\Models\IvOrganised;
|
||||||
|
|
||||||
class FacultyController extends Controller
|
class FacultyController extends Controller
|
||||||
{
|
{
|
||||||
@@ -36,6 +37,17 @@ class FacultyController extends Controller
|
|||||||
return view('activities-organised.index');
|
return view('activities-organised.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function IvOrganisedForm()
|
||||||
|
{
|
||||||
|
// Logic to show the response form
|
||||||
|
return view('faculty.iv-organised-form');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function viewIvOrganisedResponses()
|
||||||
|
{
|
||||||
|
return view('iv-organised.index');
|
||||||
|
}
|
||||||
|
|
||||||
public function ActivitiesAttendedFormResponse(Request $request)
|
public function ActivitiesAttendedFormResponse(Request $request)
|
||||||
{
|
{
|
||||||
// dd($request->all(),"hello");
|
// dd($request->all(),"hello");
|
||||||
@@ -62,7 +74,6 @@ class FacultyController extends Controller
|
|||||||
$startDateTime = date('Y-m-d H:i:s', strtotime("{$validated['start_date']} {$validated['start_time']}"));
|
$startDateTime = date('Y-m-d H:i:s', strtotime("{$validated['start_date']} {$validated['start_time']}"));
|
||||||
$endDateTime = date('Y-m-d H:i:s', strtotime("{$validated['end_date']} {$validated['end_time']}"));
|
$endDateTime = date('Y-m-d H:i:s', strtotime("{$validated['end_date']} {$validated['end_time']}"));
|
||||||
|
|
||||||
// Handle the file upload
|
|
||||||
// Handle the file upload
|
// Handle the file upload
|
||||||
$proofPath = null;
|
$proofPath = null;
|
||||||
if ($request->hasFile('proof')) {
|
if ($request->hasFile('proof')) {
|
||||||
@@ -74,7 +85,7 @@ class FacultyController extends Controller
|
|||||||
$year = date('Y', strtotime($validated['start_date']));
|
$year = date('Y', strtotime($validated['start_date']));
|
||||||
|
|
||||||
// Create path structure: year/faculty_name
|
// Create path structure: year/faculty_name
|
||||||
$folderPath = 'proofs/' . $year . '/' . $username;
|
$folderPath = 'proofs/' . $year . '/' . $username . 'Activities-Attended';
|
||||||
|
|
||||||
// Store file in the specified path
|
// Store file in the specified path
|
||||||
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
||||||
@@ -107,7 +118,7 @@ class FacultyController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function ActivitiesOrganisedFormResponse(Request $request)
|
public function ActivitiesOrganisedFormResponse(Request $request)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
// Validate the request data
|
// Validate the request data
|
||||||
$validated = $request->validate([
|
$validated = $request->validate([
|
||||||
@@ -145,7 +156,7 @@ class FacultyController extends Controller
|
|||||||
$year = date('Y', strtotime($validated['start_date']));
|
$year = date('Y', strtotime($validated['start_date']));
|
||||||
|
|
||||||
// Create path structure: year/faculty_name
|
// Create path structure: year/faculty_name
|
||||||
$folderPath = 'proofs/' . $year . '/' . $username;
|
$folderPath = 'proofs/' . $year . '/' . $username . 'Activities-Organised';
|
||||||
|
|
||||||
// Store file in the specified path
|
// Store file in the specified path
|
||||||
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
||||||
@@ -177,5 +188,73 @@ class FacultyController extends Controller
|
|||||||
// Handle the exception and provide an error message
|
// Handle the exception and provide an error message
|
||||||
return back()->withErrors('An error occurred while submitting your response: ' . $e->getMessage());
|
return back()->withErrors('An error occurred while submitting your response: ' . $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function IvOrganisedFormResponse(Request $request)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
// Validate the request data
|
||||||
|
$validated = $request->validate([
|
||||||
|
'faculty_id' => 'required|exists:users,id',
|
||||||
|
'start_date' => 'required|date',
|
||||||
|
'start_time' => 'required|date_format:H:i',
|
||||||
|
'end_date' => 'required|date',
|
||||||
|
'end_time' => 'required|date_format:H:i',
|
||||||
|
'company_name' => 'required|string',
|
||||||
|
'company_address' => 'required|string',
|
||||||
|
'resource_person_name' => 'required|string',
|
||||||
|
'resource_person_contact_details' => 'required|string',
|
||||||
|
'target_audience' => 'required|string',
|
||||||
|
'student_year' => 'nullable|string',
|
||||||
|
'number_of_participants' => 'required|integer',
|
||||||
|
'objective' => 'required|string',
|
||||||
|
'outcomes' => 'required|string',
|
||||||
|
'proof' => 'nullable|mimes:jpg,jpeg,png,pdf,doc,docx,zip',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Combine start date and time
|
||||||
|
$startDateTime = date('Y-m-d H:i:s', strtotime("{$validated['start_date']} {$validated['start_time']}"));
|
||||||
|
$endDateTime = date('Y-m-d H:i:s', strtotime("{$validated['end_date']} {$validated['end_time']}"));
|
||||||
|
|
||||||
|
// Handle the file upload
|
||||||
|
$proofPath = null;
|
||||||
|
if ($request->hasFile('proof')) {
|
||||||
|
$originalName = $request->file('proof')->getClientOriginalName();
|
||||||
|
$username = auth()->user()->name;
|
||||||
|
$fileName = $username . '_' . $originalName;
|
||||||
|
|
||||||
|
// Extract year from start_date
|
||||||
|
$year = date('Y', strtotime($validated['start_date']));
|
||||||
|
|
||||||
|
// Create path structure: year/faculty_name
|
||||||
|
$folderPath = 'proofs/' . $year . '/' . $username . '/Iv_organised';
|
||||||
|
|
||||||
|
// Store file in the specified path
|
||||||
|
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save the response to the database
|
||||||
|
IvOrganised::create([
|
||||||
|
'faculty_id' => auth()->user()->id,
|
||||||
|
'start_date' => $startDateTime,
|
||||||
|
'end_date' => $endDateTime,
|
||||||
|
'company_name' => $validated['company_name'],
|
||||||
|
'company_address' => $validated['company_address'],
|
||||||
|
'resource_person_name' => $validated['resource_person_name'],
|
||||||
|
'resource_person_contact_details' => $validated['resource_person_contact_details'],
|
||||||
|
'target_audience' => $validated['target_audience'],
|
||||||
|
'student_year' => $validated['student_year'],
|
||||||
|
'number_of_participants' => $validated['number_of_participants'],
|
||||||
|
'objective' => $validated['objective'],
|
||||||
|
'outcomes' => $validated['outcomes'],
|
||||||
|
'department_id' => auth()->user()->department->id,
|
||||||
|
'proof' => $proofPath,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->route('faculty.dashboard')->with('status', 'Industrial Visit details submitted successfully');
|
||||||
|
} catch (\Exception $e) {
|
||||||
|
// Handle the exception and provide an error message
|
||||||
|
return back()->withErrors('An error occurred while submitting your response: ' . $e->getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
255
app/Http/Controllers/IvOrganisedController.php
Normal file
255
app/Http/Controllers/IvOrganisedController.php
Normal file
@@ -0,0 +1,255 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Yajra\DataTables\Facades\DataTables;
|
||||||
|
use App\Models\IvOrganised;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
|
class IvOrganisedController extends Controller
|
||||||
|
{
|
||||||
|
public function edit($id)
|
||||||
|
{
|
||||||
|
$response = IvOrganised::findOrFail($id);
|
||||||
|
|
||||||
|
return view('iv-organised.edit', compact('response'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function update(Request $request, $id)
|
||||||
|
{
|
||||||
|
$response = IvOrganised::findOrFail($id);
|
||||||
|
|
||||||
|
// Validate the request data
|
||||||
|
$validated = $request->validate([
|
||||||
|
'company_name' => 'required|string',
|
||||||
|
'company_address' => 'required|string',
|
||||||
|
'resource_person_name' => 'required|string',
|
||||||
|
'resource_person_contact_details' => 'required|string',
|
||||||
|
'target_audience' => 'required|string',
|
||||||
|
'student_year' => 'nullable|string',
|
||||||
|
'number_of_participants' => 'required|integer',
|
||||||
|
'objective' => 'required|string',
|
||||||
|
'outcomes' => 'required|string',
|
||||||
|
'start_date' => 'required|date',
|
||||||
|
'start_time' => 'required|date_format:H:i',
|
||||||
|
'end_date' => 'required|date',
|
||||||
|
'end_time' => 'required|date_format:H:i',
|
||||||
|
'proof' => 'nullable|mimes:jpg,jpeg,png,pdf,doc,docx,zip',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Combine start date and time
|
||||||
|
$startDateTime = date('Y-m-d H:i:s', strtotime("{$validated['start_date']} {$validated['start_time']}"));
|
||||||
|
$endDateTime = date('Y-m-d H:i:s', strtotime("{$validated['end_date']} {$validated['end_time']}"));
|
||||||
|
|
||||||
|
// Handle the file upload if a new file is provided
|
||||||
|
if ($request->hasFile('proof')) {
|
||||||
|
// Delete old file if exists
|
||||||
|
if ($response->proof && Storage::disk('public')->exists($response->proof)) {
|
||||||
|
Storage::disk('public')->delete($response->proof);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract year from start_date
|
||||||
|
$year = date('Y', strtotime($validated['start_date']));
|
||||||
|
$username = $response->user->name;
|
||||||
|
|
||||||
|
$originalName = $request->file('proof')->getClientOriginalName();
|
||||||
|
$fileName = $username . '_' . $originalName;
|
||||||
|
|
||||||
|
// Create path structure: year/faculty_name
|
||||||
|
$folderPath = 'proofs/' . $year . '/' . $username;
|
||||||
|
|
||||||
|
// Store file in the specified path
|
||||||
|
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
||||||
|
|
||||||
|
$response->proof = $proofPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update other fields
|
||||||
|
$response->company_name = $validated['company_name'];
|
||||||
|
$response->company_address = $validated['company_address'];
|
||||||
|
$response->resource_person_name = $validated['resource_person_name'];
|
||||||
|
$response->resource_person_contact_details = $validated['resource_person_contact_details'];
|
||||||
|
$response->target_audience = $validated['target_audience'];
|
||||||
|
$response->student_year = $validated['student_year'];
|
||||||
|
$response->number_of_participants = $validated['number_of_participants'];
|
||||||
|
$response->objective = $validated['objective'];
|
||||||
|
$response->outcomes = $validated['outcomes'];
|
||||||
|
$response->start_date = $startDateTime;
|
||||||
|
$response->end_date = $endDateTime;
|
||||||
|
|
||||||
|
$response->save();
|
||||||
|
|
||||||
|
$userRole = auth()->user()->role->name;
|
||||||
|
|
||||||
|
if ($userRole === 'Admin') {
|
||||||
|
return redirect()->route('admin.IvOrganisedResponses')
|
||||||
|
->with('status', 'Industrial visit updated successfully');
|
||||||
|
} elseif ($userRole === 'Coordinator') {
|
||||||
|
return redirect()->route('coordinator.IvOrganisedResponses')
|
||||||
|
->with('status', 'Industrial visit updated successfully');
|
||||||
|
} else {
|
||||||
|
// For regular users
|
||||||
|
return redirect()->route('faculty.IvOrganisedResponses')
|
||||||
|
->with('status', 'Industrial visit updated successfully');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function destroy($id)
|
||||||
|
{
|
||||||
|
$response = IvOrganised::findOrFail($id);
|
||||||
|
|
||||||
|
// Delete the file if it exists
|
||||||
|
if ($response->proof && Storage::disk('public')->exists($response->proof)) {
|
||||||
|
Storage::disk('public')->delete($response->proof);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response->delete();
|
||||||
|
|
||||||
|
return response()->json(['success' => 'Industrial visit record deleted successfully']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getIvOrganisedResponses()
|
||||||
|
{
|
||||||
|
$user = auth()->user();
|
||||||
|
$isAdmin = $user->role->name === 'Admin';
|
||||||
|
$isCoordinator = $user->role->name === 'Coordinator';
|
||||||
|
|
||||||
|
// Query based on role
|
||||||
|
if ($isAdmin) {
|
||||||
|
// Admin sees all records
|
||||||
|
$responses = IvOrganised::with('user', 'department');
|
||||||
|
} elseif ($isCoordinator) {
|
||||||
|
// Coordinator sees only their department's records
|
||||||
|
$responses = IvOrganised::with('user', 'department')
|
||||||
|
->whereHas('user', function ($query) use ($user) {
|
||||||
|
$query->where('department_id', $user->department_id);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Regular users see only their own records
|
||||||
|
$responses = IvOrganised::with('user', 'department')
|
||||||
|
->where('faculty_id', $user->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return DataTables::of($responses)
|
||||||
|
->addColumn('user_name', function ($response) {
|
||||||
|
return $response->user->name ?? 'Unknown';
|
||||||
|
})
|
||||||
|
->addColumn('department_name', function ($response) {
|
||||||
|
return $response->department->name ?? 'Unknown';
|
||||||
|
})
|
||||||
|
->addColumn('start_date', function ($response) {
|
||||||
|
return \Carbon\Carbon::parse($response->start_date)->format('d-m-Y');
|
||||||
|
})
|
||||||
|
->addColumn('start_time', function ($response) {
|
||||||
|
return \Carbon\Carbon::parse($response->start_date)->format('h:i A');
|
||||||
|
})
|
||||||
|
->addColumn('end_date', function ($response) {
|
||||||
|
return \Carbon\Carbon::parse($response->end_date)->format('d-m-Y');
|
||||||
|
})
|
||||||
|
->addColumn('end_time', function ($response) {
|
||||||
|
return \Carbon\Carbon::parse($response->end_date)->format('h:i A');
|
||||||
|
})
|
||||||
|
->addColumn('action', function ($response) {
|
||||||
|
$actions = [];
|
||||||
|
|
||||||
|
// 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>';
|
||||||
|
} else {
|
||||||
|
$actions[] = 'No Proof';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Edit button with role-appropriate route
|
||||||
|
$userRole = auth()->user()->role->name;
|
||||||
|
// Determine the appropriate route based on user role
|
||||||
|
if ($userRole === 'Admin') {
|
||||||
|
$editRoute = route('admin.IvOrganised.edit', $response->id);
|
||||||
|
} elseif ($userRole === 'Coordinator') {
|
||||||
|
$editRoute = route('coordinator.IvOrganised.edit', $response->id);
|
||||||
|
} else {
|
||||||
|
$editRoute = route('faculty.IvOrganised.edit', $response->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
$actions[] = '<a href="' . $editRoute . '" class="btn btn-sm btn-info mx-1">Edit</a>';
|
||||||
|
|
||||||
|
$deleteRoute = route('ivOrganised.destroy', $response->id);
|
||||||
|
$actions[] = '<button type="button" class="btn btn-sm btn-danger delete-btn" data-id="' . $response->id . '" data-url="' . $deleteRoute . '">Delete</button>';
|
||||||
|
|
||||||
|
return implode(' ', $actions);
|
||||||
|
})
|
||||||
|
->rawColumns(['action'])
|
||||||
|
->make(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
// Validate the request data
|
||||||
|
$validated = $request->validate([
|
||||||
|
'company_name' => 'required|string',
|
||||||
|
'company_address' => 'required|string',
|
||||||
|
'resource_person_name' => 'required|string',
|
||||||
|
'resource_person_contact_details' => 'required|string',
|
||||||
|
'target_audience' => 'required|string',
|
||||||
|
'student_year' => 'nullable|string',
|
||||||
|
'number_of_participants' => 'required|integer',
|
||||||
|
'objective' => 'required|string',
|
||||||
|
'outcomes' => 'required|string',
|
||||||
|
'start_date' => 'required|date',
|
||||||
|
'start_time' => 'required|date_format:H:i',
|
||||||
|
'end_date' => 'required|date',
|
||||||
|
'end_time' => 'required|date_format:H:i',
|
||||||
|
'faculty_id' => 'required|exists:users,id',
|
||||||
|
'department_id' => 'required|exists:departments,id',
|
||||||
|
'proof' => 'required|mimes:jpg,jpeg,png,pdf,doc,docx,zip',
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Combine start date and time
|
||||||
|
$startDateTime = date('Y-m-d H:i:s', strtotime("{$validated['start_date']} {$validated['start_time']}"));
|
||||||
|
$endDateTime = date('Y-m-d H:i:s', strtotime("{$validated['end_date']} {$validated['end_time']}"));
|
||||||
|
|
||||||
|
// Create new record
|
||||||
|
$ivOrganised = new IvOrganised();
|
||||||
|
$ivOrganised->company_name = $validated['company_name'];
|
||||||
|
$ivOrganised->company_address = $validated['company_address'];
|
||||||
|
$ivOrganised->resource_person_name = $validated['resource_person_name'];
|
||||||
|
$ivOrganised->resource_person_contact_details = $validated['resource_person_contact_details'];
|
||||||
|
$ivOrganised->target_audience = $validated['target_audience'];
|
||||||
|
$ivOrganised->student_year = $validated['student_year'];
|
||||||
|
$ivOrganised->number_of_participants = $validated['number_of_participants'];
|
||||||
|
$ivOrganised->objective = $validated['objective'];
|
||||||
|
$ivOrganised->outcomes = $validated['outcomes'];
|
||||||
|
$ivOrganised->start_date = $startDateTime;
|
||||||
|
$ivOrganised->end_date = $endDateTime;
|
||||||
|
$ivOrganised->faculty_id = $validated['faculty_id'];
|
||||||
|
$ivOrganised->department_id = $validated['department_id'];
|
||||||
|
|
||||||
|
// Handle the file upload
|
||||||
|
if ($request->hasFile('proof')) {
|
||||||
|
$user = auth()->user();
|
||||||
|
$year = date('Y', strtotime($validated['start_date']));
|
||||||
|
$username = $user->name;
|
||||||
|
|
||||||
|
$originalName = $request->file('proof')->getClientOriginalName();
|
||||||
|
$fileName = $username . '_' . $originalName;
|
||||||
|
|
||||||
|
// Create path structure: year/faculty_name
|
||||||
|
$folderPath = 'proofs/' . $year . '/' . $username;
|
||||||
|
|
||||||
|
// Store file in the specified path
|
||||||
|
$proofPath = $request->file('proof')->storeAs($folderPath, $fileName, 'public');
|
||||||
|
|
||||||
|
$ivOrganised->proof = $proofPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
$ivOrganised->save();
|
||||||
|
|
||||||
|
return redirect()->route('faculty.IvOrganisedResponses')
|
||||||
|
->with('status', 'Industrial visit submitted successfully');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('iv-organised.create');
|
||||||
|
}
|
||||||
|
}
|
||||||
48
app/Models/IvOrganised.php
Normal file
48
app/Models/IvOrganised.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
|
||||||
|
class IvOrganised extends Model
|
||||||
|
{
|
||||||
|
use HasFactory;
|
||||||
|
|
||||||
|
protected $table = 'iv_organiseds';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'faculty_id',
|
||||||
|
'start_date',
|
||||||
|
'end_date',
|
||||||
|
'company_name',
|
||||||
|
'company_address',
|
||||||
|
'resource_person_name',
|
||||||
|
'resource_person_contact_details',
|
||||||
|
'target_audience',
|
||||||
|
'student_year',
|
||||||
|
'number_of_participants',
|
||||||
|
'objective',
|
||||||
|
'outcomes',
|
||||||
|
'department_id',
|
||||||
|
'proof'
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'start_date' => 'datetime',
|
||||||
|
'end_date' => 'datetime',
|
||||||
|
'number_of_participants' => 'integer',
|
||||||
|
];
|
||||||
|
|
||||||
|
// Relationship with User (Faculty)
|
||||||
|
public function user()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class, 'faculty_id');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Relationship with Department
|
||||||
|
public function department()
|
||||||
|
{
|
||||||
|
return $this->belongsTo(Department::class, 'department_id');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('iv_organiseds', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->unsignedBigInteger('faculty_id'); // Organising faculty (Convenor/Coordinator)
|
||||||
|
$table->dateTime('start_date');
|
||||||
|
$table->dateTime('end_date');
|
||||||
|
$table->string('company_name'); // Name of the Company/field/institute
|
||||||
|
$table->text('company_address'); // Address of the company/field/institute
|
||||||
|
$table->string('resource_person_name');
|
||||||
|
$table->text('resource_person_contact_details');
|
||||||
|
$table->string('target_audience'); // (faculty/student)
|
||||||
|
$table->string('student_year')->nullable(); // Year of study if students
|
||||||
|
$table->integer('number_of_participants');
|
||||||
|
$table->text('objective');
|
||||||
|
$table->text('outcomes');
|
||||||
|
$table->unsignedBigInteger('department_id');
|
||||||
|
$table->string('proof')->nullable(); // For file path
|
||||||
|
$table->foreign('faculty_id')->references('id')->on('users')->onDelete('cascade');
|
||||||
|
$table->foreign('department_id')->references('id')->on('departments')->onDelete('cascade');
|
||||||
|
$table->timestamps();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('iv_organiseds');
|
||||||
|
}
|
||||||
|
};
|
||||||
154
resources/views/faculty/iv-organised-form.blade.php
Normal file
154
resources/views/faculty/iv-organised-form.blade.php
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||||
|
<div class="bg-white overflow-hidden shadow sm:rounded-lg">
|
||||||
|
<div class="px-4 py-5 sm:px-6">
|
||||||
|
<h3 class="text-lg leading-6 font-medium text-gray-900">
|
||||||
|
Submit Industrial Visit Details
|
||||||
|
</h3>
|
||||||
|
<p class="mt-1 max-w-2xl text-sm text-gray-500">
|
||||||
|
Fill in the details of the industrial visit you organised.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="border-t border-gray-200">
|
||||||
|
<form method="POST" action="{{ route('faculty.IvOrganisedFormResponse') }}" enctype="multipart/form-data">
|
||||||
|
@csrf
|
||||||
|
<div class="px-4 py-5 sm:px-6">
|
||||||
|
<div class="space-y-6">
|
||||||
|
|
||||||
|
<!-- Company Name -->
|
||||||
|
<div>
|
||||||
|
<label for="company_name" class="block text-sm font-medium text-gray-700">Name of the Company/Field/Institute</label>
|
||||||
|
<input type="text" name="company_name" id="company_name" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Company Address -->
|
||||||
|
<div>
|
||||||
|
<label for="company_address" class="block text-sm font-medium text-gray-700">Address of the Company/Field/Institute</label>
|
||||||
|
<input type="text" name="company_address" id="company_address" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Resource Person Details -->
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<label for="resource_person_name" class="block text-sm font-medium text-gray-700">Resource Person Name</label>
|
||||||
|
<input type="text" name="resource_person_name" id="resource_person_name" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" required>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="resource_person_contact_details" class="block text-sm font-medium text-gray-700">Resource Person Contact Details</label>
|
||||||
|
<input type="text" name="resource_person_contact_details" id="resource_person_contact_details" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Target Audience and Student Year -->
|
||||||
|
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<label for="target_audience" class="block text-sm font-medium text-gray-700">Target Audience</label>
|
||||||
|
<select name="target_audience" id="target_audience" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" required onchange="toggleStudentYear()">
|
||||||
|
<option value="">Select</option>
|
||||||
|
<option value="faculty">Faculty</option>
|
||||||
|
<option value="student">Student</option>
|
||||||
|
<option value="both">Both</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div id="student_year_container" class="hidden">
|
||||||
|
<label for="student_year" class="block text-sm font-medium text-gray-700">Year of Study</label>
|
||||||
|
<input type="text" name="student_year" id="student_year" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Number of Participants -->
|
||||||
|
<div>
|
||||||
|
<label for="number_of_participants" class="block text-sm font-medium text-gray-700">Number of Participants</label>
|
||||||
|
<input type="number" name="number_of_participants" id="number_of_participants" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Department and Faculty Name -->
|
||||||
|
<div class="grid grid-cols-2 sm:grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<label for="department" class="block text-sm font-medium text-gray-700">Department</label>
|
||||||
|
<input type="text" name="department" id="department" value="{{ auth()->user()->department->name }}" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm bg-gray-100" disabled>
|
||||||
|
<input type="hidden" name="department_id" value="{{ auth()->user()->department_id }}">
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="faculty_name" class="block text-sm font-medium text-gray-700">Faculty Name</label>
|
||||||
|
<input type="text" name="faculty_name" id="faculty_name" value="{{ auth()->user()->name }}" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm bg-gray-100" disabled>
|
||||||
|
<input type="hidden" name="faculty_id" value="{{ auth()->user()->id }}">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Start Date/Time, End Date/Time -->
|
||||||
|
<div class="grid grid-cols-2 gap-4">
|
||||||
|
<div>
|
||||||
|
<label for="start_date" class="block text-sm font-medium text-gray-700">Start Date</label>
|
||||||
|
<input type="date" name="start_date" id="start_date" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" required>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="start_time" class="block text-sm font-medium text-gray-700">Start Time</label>
|
||||||
|
<input type="time" name="start_time" id="start_time" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" required>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="end_date" class="block text-sm font-medium text-gray-700">End Date</label>
|
||||||
|
<input type="date" name="end_date" id="end_date" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" required>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label for="end_time" class="block text-sm font-medium text-gray-700">End Time</label>
|
||||||
|
<input type="time" name="end_time" id="end_time" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Objective -->
|
||||||
|
<div>
|
||||||
|
<label for="objective" class="block text-sm font-medium text-gray-700">Objective of Industrial Visit</label>
|
||||||
|
<textarea name="objective" id="objective" rows="3" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" required></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Outcomes -->
|
||||||
|
<div>
|
||||||
|
<label for="outcomes" class="block text-sm font-medium text-gray-700">Outcomes of Industrial Visit</label>
|
||||||
|
<textarea name="outcomes" id="outcomes" rows="3" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" required></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Proof Document -->
|
||||||
|
<div>
|
||||||
|
<label for="proof" class="block text-sm font-medium text-gray-700">Upload Proof/Document</label>
|
||||||
|
<input type="file" name="proof" id="proof" class="block w-full mt-1 border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" accept=".jpg,.jpeg,.png,.pdf,.doc,.docx,.zip" required>
|
||||||
|
<p class="mt-1 text-xs text-gray-500">Accepted formats: JPG, JPEG, PNG, PDF, DOC, DOCX, ZIP</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Submit Button -->
|
||||||
|
<div class="px-4 py-3 sm:px-6 text-center mt-4">
|
||||||
|
<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">
|
||||||
|
Submit Industrial Visit
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function toggleStudentYear() {
|
||||||
|
const targetAudience = document.getElementById('target_audience').value;
|
||||||
|
const studentYearContainer = document.getElementById('student_year_container');
|
||||||
|
const studentYearField = document.getElementById('student_year');
|
||||||
|
|
||||||
|
if (targetAudience === 'faculty') {
|
||||||
|
studentYearContainer.classList.add('hidden');
|
||||||
|
studentYearField.required = false;
|
||||||
|
studentYearField.value = '';
|
||||||
|
} else {
|
||||||
|
studentYearContainer.classList.remove('hidden');
|
||||||
|
studentYearField.required = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize on page load
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
toggleStudentYear();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endsection
|
||||||
180
resources/views/iv-organised/edit.blade.php
Normal file
180
resources/views/iv-organised/edit.blade.php
Normal file
@@ -0,0 +1,180 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6">
|
||||||
|
<div class="bg-white overflow-hidden shadow sm:rounded-lg">
|
||||||
|
<div class="px-4 py-5 sm:px-6">
|
||||||
|
<h3 class="text-xl leading-6 font-semibold text-gray-900">
|
||||||
|
Edit Industrial Visit
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="px-4 py-5 sm:p-6">
|
||||||
|
@if ($errors->any())
|
||||||
|
<div class="bg-red-100 border border-red-400 text-red-700 px-4 py-3 rounded mb-4">
|
||||||
|
<ul>
|
||||||
|
@foreach ($errors->all() as $error)
|
||||||
|
<li>{{ $error }}</li>
|
||||||
|
@endforeach
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
<form action="{{ request()->is('admin/*') ? route('admin.IvOrganised.update', $response->id) : (request()->is('coordinator/*') ? route('coordinator.IvOrganised.update', $response->id) : route('faculty.IvOrganised.update', $response->id)) }}" method="POST" enctype="multipart/form-data">
|
||||||
|
@csrf
|
||||||
|
@method('PUT')
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
|
<!-- Company Name -->
|
||||||
|
<div>
|
||||||
|
<label for="company_name" class="block text-sm font-medium text-gray-700">Name of the Company/Field/Institute</label>
|
||||||
|
<input type="text" name="company_name" id="company_name" value="{{ old('company_name', $response->company_name) }}" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Company Address -->
|
||||||
|
<div>
|
||||||
|
<label for="company_address" class="block text-sm font-medium text-gray-700">Address of the Company/Field/Institute</label>
|
||||||
|
<input type="text" name="company_address" id="company_address" value="{{ old('company_address', $response->company_address) }}" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Resource Person Name -->
|
||||||
|
<div>
|
||||||
|
<label for="resource_person_name" class="block text-sm font-medium text-gray-700">Resource Person Name</label>
|
||||||
|
<input type="text" name="resource_person_name" id="resource_person_name" value="{{ old('resource_person_name', $response->resource_person_name) }}" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Resource Person Contact Details -->
|
||||||
|
<div>
|
||||||
|
<label for="resource_person_contact_details" class="block text-sm font-medium text-gray-700">Resource Person Contact Details</label>
|
||||||
|
<input type="text" name="resource_person_contact_details" id="resource_person_contact_details" value="{{ old('resource_person_contact_details', $response->resource_person_contact_details) }}" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Target Audience -->
|
||||||
|
<div>
|
||||||
|
<label for="target_audience" class="block text-sm font-medium text-gray-700">Target Audience</label>
|
||||||
|
<select name="target_audience" id="target_audience" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" required>
|
||||||
|
<option value="faculty" {{ old('target_audience', $response->target_audience) == 'faculty' ? 'selected' : '' }}>Faculty</option>
|
||||||
|
<option value="student" {{ old('target_audience', $response->target_audience) == 'student' ? 'selected' : '' }}>Student</option>
|
||||||
|
<option value="both" {{ old('target_audience', $response->target_audience) == 'both' ? 'selected' : '' }}>Both</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Student Year (conditionally displayed) -->
|
||||||
|
<div id="student_year_container" class="{{ old('target_audience', $response->target_audience) == 'faculty' ? 'hidden' : '' }}">
|
||||||
|
<label for="student_year" class="block text-sm font-medium text-gray-700">Year of Study</label>
|
||||||
|
<input type="text" name="student_year" id="student_year" value="{{ old('student_year', $response->student_year) }}" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" {{ old('target_audience', $response->target_audience) == 'faculty' ? '' : 'required' }}>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Number of Participants -->
|
||||||
|
<div>
|
||||||
|
<label for="number_of_participants" class="block text-sm font-medium text-gray-700">Number of Participants</label>
|
||||||
|
<input type="number" name="number_of_participants" id="number_of_participants" value="{{ old('number_of_participants', $response->number_of_participants) }}" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Department -->
|
||||||
|
<div>
|
||||||
|
<label for="department" class="block text-sm font-medium text-gray-700">Department</label>
|
||||||
|
<input type="text" id="department" value="{{ $response->department->name ?? 'Unknown' }}" class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md bg-gray-100" disabled>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Faculty -->
|
||||||
|
<div>
|
||||||
|
<label for="faculty" class="block text-sm font-medium text-gray-700">Organising Faculty (Convenor/Coordinator)</label>
|
||||||
|
<input type="text" id="faculty" value="{{ $response->faculty->name ?? 'Unknown' }}" class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md bg-gray-100" disabled>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Start Date -->
|
||||||
|
<div>
|
||||||
|
<label for="start_date" class="block text-sm font-medium text-gray-700">Start Date</label>
|
||||||
|
<input type="date" name="start_date" id="start_date" value="{{ old('start_date', \Carbon\Carbon::parse($response->start_date)->format('Y-m-d')) }}" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Start Time -->
|
||||||
|
<div>
|
||||||
|
<label for="start_time" class="block text-sm font-medium text-gray-700">Start Time</label>
|
||||||
|
<input type="time" name="start_time" id="start_time" value="{{ old('start_time', \Carbon\Carbon::parse($response->start_date)->format('H:i')) }}" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- End Date -->
|
||||||
|
<div>
|
||||||
|
<label for="end_date" class="block text-sm font-medium text-gray-700">End Date</label>
|
||||||
|
<input type="date" name="end_date" id="end_date" value="{{ old('end_date', \Carbon\Carbon::parse($response->end_date)->format('Y-m-d')) }}" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- End Time -->
|
||||||
|
<div>
|
||||||
|
<label for="end_time" class="block text-sm font-medium text-gray-700">End Time</label>
|
||||||
|
<input type="time" name="end_time" id="end_time" value="{{ old('end_time', \Carbon\Carbon::parse($response->end_date)->format('H:i')) }}" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Objective -->
|
||||||
|
<div class="col-span-1 md:col-span-2">
|
||||||
|
<label for="objective" class="block text-sm font-medium text-gray-700">Objective of Activity</label>
|
||||||
|
<textarea name="objective" id="objective" rows="3" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" required>{{ old('objective', $response->objective) }}</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Outcomes -->
|
||||||
|
<div class="col-span-1 md:col-span-2">
|
||||||
|
<label for="outcomes" class="block text-sm font-medium text-gray-700">Outcomes of Activity</label>
|
||||||
|
<textarea name="outcomes" id="outcomes" rows="3" class="mt-1 focus:ring-indigo-500 focus:border-indigo-500 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" required>{{ old('outcomes', $response->outcomes) }}</textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Proof -->
|
||||||
|
<div class="col-span-1 md:col-span-2">
|
||||||
|
<label for="proof" class="block text-sm font-medium text-gray-700">Proof</label>
|
||||||
|
@if ($response->proof)
|
||||||
|
<div class="mb-2">
|
||||||
|
<span class="text-sm text-gray-600">Current file:</span>
|
||||||
|
<a href="{{ asset('storage/' . $response->proof) }}" target="_blank" class="ml-2 text-blue-600 hover:text-blue-800">View</a>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
<input type="file" name="proof" id="proof" class="mt-1 block w-full text-sm text-gray-500
|
||||||
|
file:mr-4 file:py-2 file:px-4
|
||||||
|
file:rounded-full file:border-0
|
||||||
|
file:text-sm file:font-semibold
|
||||||
|
file:bg-blue-50 file:text-blue-700
|
||||||
|
hover:file:bg-blue-100">
|
||||||
|
<p class="mt-1 text-sm text-gray-500">Upload new proof (JPG, JPEG, PNG, PDF, DOC, DOCX, ZIP)</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mt-6 flex items-center justify-end">
|
||||||
|
<a href="{{ request()->is('admin/*') ? route('admin.IvOrganisedResponses') : (request()->is('coordinator/*') ? route('coordinator.IvOrganisedResponses') : route('faculty.IvOrganisedResponses')) }}" 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">
|
||||||
|
Update
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('scripts')
|
||||||
|
<script>
|
||||||
|
document.addEventListener('DOMContentLoaded', function() {
|
||||||
|
// Handle showing/hiding student year field based on target audience
|
||||||
|
const targetAudienceField = document.getElementById('target_audience');
|
||||||
|
const studentYearContainer = document.getElementById('student_year_container');
|
||||||
|
const studentYearField = document.getElementById('student_year');
|
||||||
|
|
||||||
|
function toggleStudentYear() {
|
||||||
|
if (targetAudienceField.value === 'faculty') {
|
||||||
|
studentYearContainer.classList.add('hidden');
|
||||||
|
studentYearField.required = false;
|
||||||
|
studentYearField.value = '';
|
||||||
|
} else {
|
||||||
|
studentYearContainer.classList.remove('hidden');
|
||||||
|
studentYearField.required = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
targetAudienceField.addEventListener('change', toggleStudentYear);
|
||||||
|
|
||||||
|
// Initialize on page load
|
||||||
|
toggleStudentYear();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endsection
|
||||||
204
resources/views/iv-organised/index.blade.php
Normal file
204
resources/views/iv-organised/index.blade.php
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="max-w-full mx-auto px-4 sm:px-6 lg:px-8">
|
||||||
|
<div class="bg-white overflow-hidden shadow sm:rounded-lg">
|
||||||
|
<div class="px-4 py-5 sm:px-6">
|
||||||
|
<h3 class="text-xl leading-6 font-semibold text-gray-900">
|
||||||
|
All Industrial Visits Organised
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div class="px-4 py-5 sm:px-6">
|
||||||
|
<div class="overflow-x-auto w-full max-w-screen-lg mx-auto">
|
||||||
|
<table id="responses-table" class="table-auto w-full table-striped border-collapse border border-gray-200 rounded-lg">
|
||||||
|
<thead class="bg-gray-100">
|
||||||
|
<tr>
|
||||||
|
<th class="px-4 py-2 border border-gray-200">ID</th>
|
||||||
|
<th class="px-4 py-2 border border-gray-200">Company Name</th>
|
||||||
|
<th class="px-4 py-2 border border-gray-200">Resource Person</th>
|
||||||
|
<th class="px-4 py-2 border border-gray-200">Target Audience</th>
|
||||||
|
<th class="px-4 py-2 border border-gray-200">Department</th>
|
||||||
|
<th class="px-4 py-2 border border-gray-200">Faculty</th>
|
||||||
|
<th class="px-4 py-2 border border-gray-200">Start Date</th>
|
||||||
|
<th class="px-4 py-2 border border-gray-200">End Date</th>
|
||||||
|
<th class="px-4 py-2 border border-gray-200">Student Year</th>
|
||||||
|
<th class="px-4 py-2 border border-gray-200">Participants</th>
|
||||||
|
<th class="px-4 py-2 border border-gray-200">Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
@section('scripts')
|
||||||
|
<!-- DataTables JS -->
|
||||||
|
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.13.1/css/jquery.dataTables.min.css">
|
||||||
|
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.13.1/css/dataTables.bootstrap5.min.css">
|
||||||
|
<script src="https://code.jquery.com/jquery-3.5.1.js"></script>
|
||||||
|
<script src="https://cdn.datatables.net/1.13.1/js/jquery.dataTables.min.js"></script>
|
||||||
|
<script src="https://cdn.datatables.net/1.13.1/js/dataTables.bootstrap5.min.js"></script>
|
||||||
|
<script src="https://cdn.datatables.net/buttons/2.2.3/js/dataTables.buttons.min.js"></script>
|
||||||
|
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.html5.min.js"></script>
|
||||||
|
<script src="https://cdn.datatables.net/buttons/2.2.3/js/buttons.print.min.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
const sheetName = "Industrial Visits Organised";
|
||||||
|
|
||||||
|
var initAjaxRoute = function(route) {
|
||||||
|
table = $("#responses-table").DataTable({
|
||||||
|
fnDestroy: true,
|
||||||
|
processing: true,
|
||||||
|
serverSide: true,
|
||||||
|
responsive: true,
|
||||||
|
ajax: {
|
||||||
|
url: route,
|
||||||
|
},
|
||||||
|
columns: [{
|
||||||
|
data: 'id',
|
||||||
|
name: 'id'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'company_name',
|
||||||
|
name: 'company_name',
|
||||||
|
orderable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'resource_person_name',
|
||||||
|
name: 'resource_person_name',
|
||||||
|
orderable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'target_audience',
|
||||||
|
name: 'target_audience',
|
||||||
|
orderable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'department_name',
|
||||||
|
name: 'department',
|
||||||
|
orderable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'user_name',
|
||||||
|
name: 'user_name',
|
||||||
|
orderable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'start_date',
|
||||||
|
name: 'start_date',
|
||||||
|
orderable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'end_date',
|
||||||
|
name: 'end_date',
|
||||||
|
orderable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'student_year',
|
||||||
|
name: 'student_year',
|
||||||
|
orderable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'number_of_participants',
|
||||||
|
name: 'number_of_participants',
|
||||||
|
orderable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: 'action',
|
||||||
|
name: 'action',
|
||||||
|
orderable: false,
|
||||||
|
searchable: false
|
||||||
|
},
|
||||||
|
],
|
||||||
|
columnDefs: [{
|
||||||
|
targets: '_all',
|
||||||
|
className: 'text-center wrap-text'
|
||||||
|
}, ],
|
||||||
|
dom: 'Bfrtip',
|
||||||
|
buttons: [{
|
||||||
|
extend: 'copy',
|
||||||
|
title: sheetName,
|
||||||
|
exportOptions: exportOptions()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
extend: 'csv',
|
||||||
|
title: sheetName,
|
||||||
|
exportOptions: exportOptions()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
extend: 'excel',
|
||||||
|
title: sheetName,
|
||||||
|
exportOptions: exportOptions()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
extend: 'pdf',
|
||||||
|
title: sheetName,
|
||||||
|
exportOptions: exportOptions()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
extend: 'print',
|
||||||
|
title: sheetName,
|
||||||
|
exportOptions: exportOptions()
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
// Delete button event handler
|
||||||
|
$('#responses-table').on('click', '.delete-btn', function() {
|
||||||
|
if (confirm('Are you sure you want to delete this record?')) {
|
||||||
|
const id = $(this).data('id');
|
||||||
|
const url = $(this).data('url');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
type: 'DELETE',
|
||||||
|
data: {
|
||||||
|
"_token": "{{ csrf_token() }}"
|
||||||
|
},
|
||||||
|
success: function(result) {
|
||||||
|
table.ajax.reload();
|
||||||
|
alert('Record deleted successfully');
|
||||||
|
},
|
||||||
|
error: function(error) {
|
||||||
|
console.error(error);
|
||||||
|
alert('Error deleting record');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function exportOptions() {
|
||||||
|
return {
|
||||||
|
columns: ':visible',
|
||||||
|
format: {
|
||||||
|
body: function(data, row, column, node) {
|
||||||
|
if ($(node).find('select').length) {
|
||||||
|
return $(node).find("select option:selected").text();
|
||||||
|
}
|
||||||
|
return $(node).text();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set appropriate route based on user role
|
||||||
|
const userRole = "{{ auth()->user()->role->name }}";
|
||||||
|
let dataRoute = "{{ route('admin.IvOrganisedResponses.data') }}";
|
||||||
|
|
||||||
|
if (userRole === 'Coordinator') {
|
||||||
|
dataRoute = "{{ route('coordinator.IvOrganisedResponses.data') }}";
|
||||||
|
}
|
||||||
|
if (userRole === 'Faculty') {
|
||||||
|
dataRoute = "{{ route('faculty.IvOrganisedResponses.data') }}";
|
||||||
|
}
|
||||||
|
|
||||||
|
initAjaxRoute(dataRoute);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
@endsection
|
||||||
@@ -24,6 +24,10 @@
|
|||||||
<x-nav-link :href="route('admin.ActivitiesOrganisedResponses')" :active="request()->routeIs('admin.ActivitiesOrganisedResponses')">
|
<x-nav-link :href="route('admin.ActivitiesOrganisedResponses')" :active="request()->routeIs('admin.ActivitiesOrganisedResponses')">
|
||||||
{{ __('Activities Organised') }}
|
{{ __('Activities Organised') }}
|
||||||
</x-nav-link>
|
</x-nav-link>
|
||||||
|
<x-nav-link :href="route('admin.IvOrganisedResponses')" :active="request()->routeIs('admin.IvOrganisedResponses')">
|
||||||
|
{{ __('IV Organised') }}
|
||||||
|
</x-nav-link>
|
||||||
|
<!-- Coordinator Routes -->
|
||||||
@elseif(auth()->user()->role->name === 'Coordinator')
|
@elseif(auth()->user()->role->name === 'Coordinator')
|
||||||
<x-nav-link :href="route('coordinator.ActivitiesAttendedResponses')" :active="request()->routeIs('coordinator.ActivitiesAttendedResponses')">
|
<x-nav-link :href="route('coordinator.ActivitiesAttendedResponses')" :active="request()->routeIs('coordinator.ActivitiesAttendedResponses')">
|
||||||
{{ __('Activities Attended') }}
|
{{ __('Activities Attended') }}
|
||||||
@@ -31,6 +35,10 @@
|
|||||||
<x-nav-link :href="route('coordinator.ActivitiesOrganisedResponses')" :active="request()->routeIs('coordinator.ActivitiesOrganisedResponses')">
|
<x-nav-link :href="route('coordinator.ActivitiesOrganisedResponses')" :active="request()->routeIs('coordinator.ActivitiesOrganisedResponses')">
|
||||||
{{ __('Activities Organised') }}
|
{{ __('Activities Organised') }}
|
||||||
</x-nav-link>
|
</x-nav-link>
|
||||||
|
<x-nav-link :href="route('coordinator.IvOrganisedResponses')" :active="request()->routeIs('coordinator.IvOrganisedResponses')">
|
||||||
|
{{ __('IV Organised') }}
|
||||||
|
</x-nav-link>
|
||||||
|
<!-- Faculty Routes -->
|
||||||
@elseif(auth()->user()->role->name === 'Faculty')
|
@elseif(auth()->user()->role->name === 'Faculty')
|
||||||
<x-nav-link :href="route('faculty.ActivitiesAttendedForm')" :active="request()->routeIs('faculty.ActivitiesAttendedForm')">
|
<x-nav-link :href="route('faculty.ActivitiesAttendedForm')" :active="request()->routeIs('faculty.ActivitiesAttendedForm')">
|
||||||
{{ __('Activities Attended') }}
|
{{ __('Activities Attended') }}
|
||||||
@@ -38,6 +46,9 @@
|
|||||||
<x-nav-link :href="route('faculty.ActivitiesOrganisedForm')" :active="request()->routeIs('faculty.ActivitiesOrganisedForm')">
|
<x-nav-link :href="route('faculty.ActivitiesOrganisedForm')" :active="request()->routeIs('faculty.ActivitiesOrganisedForm')">
|
||||||
{{ __('Activities Organised') }}
|
{{ __('Activities Organised') }}
|
||||||
</x-nav-link>
|
</x-nav-link>
|
||||||
|
<x-nav-link :href="route('faculty.IvOrganisedForm')" :active="request()->routeIs('faculty.IvOrganisedForm')">
|
||||||
|
{{ __('Iv Organised') }}
|
||||||
|
</x-nav-link>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ use App\Http\Controllers\UserController;
|
|||||||
use App\Http\Controllers\AdminController;
|
use App\Http\Controllers\AdminController;
|
||||||
use App\Http\Controllers\CoordinatorController;
|
use App\Http\Controllers\CoordinatorController;
|
||||||
use App\Http\Controllers\FacultyController;
|
use App\Http\Controllers\FacultyController;
|
||||||
|
use App\Http\Controllers\IvOrganisedController;
|
||||||
use App\Http\Middleware\CheckRole;
|
use App\Http\Middleware\CheckRole;
|
||||||
|
|
||||||
Route::get('/', function () {
|
Route::get('/', function () {
|
||||||
@@ -44,6 +45,9 @@ Route::delete('/activities-attended/{id}', [ActivitiesAttendedController::class,
|
|||||||
// Activities Organised common routes
|
// Activities Organised common routes
|
||||||
Route::delete('/activities-organised/{id}', [ActivitiesOrganisedController::class, 'destroy'])->name('activitiesOrganised.destroy');
|
Route::delete('/activities-organised/{id}', [ActivitiesOrganisedController::class, 'destroy'])->name('activitiesOrganised.destroy');
|
||||||
|
|
||||||
|
// Iv Organised common routes
|
||||||
|
Route::delete('/iv-organised/{id}', [IvOrganisedController::class, 'destroy'])->name('ivOrganised.destroy');
|
||||||
|
|
||||||
// Admin routes
|
// Admin routes
|
||||||
Route::middleware(['auth', CheckRole::class . ':Admin'])->group(function () {
|
Route::middleware(['auth', CheckRole::class . ':Admin'])->group(function () {
|
||||||
Route::get('/admin', [AdminController::class, 'index'])->name('admin.dashboard');
|
Route::get('/admin', [AdminController::class, 'index'])->name('admin.dashboard');
|
||||||
@@ -61,6 +65,13 @@ Route::middleware(['auth', CheckRole::class . ':Admin'])->group(function () {
|
|||||||
Route::get('/admin/activities-organised/{id}/edit', [ActivitiesOrganisedController::class, 'edit'])->name('admin.ActivitiesOrganised.edit');
|
Route::get('/admin/activities-organised/{id}/edit', [ActivitiesOrganisedController::class, 'edit'])->name('admin.ActivitiesOrganised.edit');
|
||||||
Route::put('/admin/activities-organised/{id}', [ActivitiesOrganisedController::class, 'update'])->name('admin.ActivitiesOrganised.update');
|
Route::put('/admin/activities-organised/{id}', [ActivitiesOrganisedController::class, 'update'])->name('admin.ActivitiesOrganised.update');
|
||||||
Route::delete('/admin/activities-organised/{id}', [ActivitiesOrganisedController::class, 'destroy'])->name('admin.ActivitiesOrganised.destroy');
|
Route::delete('/admin/activities-organised/{id}', [ActivitiesOrganisedController::class, 'destroy'])->name('admin.ActivitiesOrganised.destroy');
|
||||||
|
|
||||||
|
// IV Organised Routes
|
||||||
|
Route::get('/admin/IvOrganisedResponses', [AdminController::class, 'viewIvOrganisedResponses'])->name('admin.IvOrganisedResponses');
|
||||||
|
Route::get('/admin/IvOrganisedResponses/data', [IvOrganisedController::class, 'getIvOrganisedResponses'])->name('admin.IvOrganisedResponses.data');
|
||||||
|
Route::get('/admin/iv-organised/{id}/edit', [IvOrganisedController::class, 'edit'])->name('admin.IvOrganised.edit');
|
||||||
|
Route::put('/admin/iv-organised/{id}', [IvOrganisedController::class, 'update'])->name('admin.IvOrganised.update');
|
||||||
|
Route::delete('/admin/iv-organised/{id}', [IvOrganisedController::class, 'destroy'])->name('admin.IvOrganised.destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Coordinator routes
|
// Coordinator routes
|
||||||
@@ -80,6 +91,13 @@ Route::middleware(['auth', CheckRole::class . ':Coordinator'])->group(function (
|
|||||||
Route::get('/coordinator/activities-organised/{id}/edit', [ActivitiesOrganisedController::class, 'edit'])->name('coordinator.ActivitiesOrganised.edit');
|
Route::get('/coordinator/activities-organised/{id}/edit', [ActivitiesOrganisedController::class, 'edit'])->name('coordinator.ActivitiesOrganised.edit');
|
||||||
Route::put('/coordinator/activities-organised/{id}', [ActivitiesOrganisedController::class, 'update'])->name('coordinator.ActivitiesOrganised.update');
|
Route::put('/coordinator/activities-organised/{id}', [ActivitiesOrganisedController::class, 'update'])->name('coordinator.ActivitiesOrganised.update');
|
||||||
Route::delete('/coordinator/activities-organised/{id}', [ActivitiesOrganisedController::class, 'destroy'])->name('coordinator.ActivitiesOrganised.destroy');
|
Route::delete('/coordinator/activities-organised/{id}', [ActivitiesOrganisedController::class, 'destroy'])->name('coordinator.ActivitiesOrganised.destroy');
|
||||||
|
|
||||||
|
// Iv Organised Routes
|
||||||
|
Route::get('/coordinator/IvOrganisedResponses', [CoordinatorController::class, 'viewIvOrganisedResponses'])->name('coordinator.IvOrganisedResponses');
|
||||||
|
Route::get('/coordinator/IvOrganisedResponses/data', [IvOrganisedController::class, 'getIvOrganisedResponses'])->name('coordinator.IvOrganisedResponses.data');
|
||||||
|
Route::get('/coordinator/iv-organised/{id}/edit', [IvOrganisedController::class, 'edit'])->name('coordinator.IvOrganised.edit');
|
||||||
|
Route::put('/coordinator/iv-organised/{id}', [IvOrganisedController::class, 'update'])->name('coordinator.IvOrganised.update');
|
||||||
|
Route::delete('/coordinator/iv-organised/{id}', [IvOrganisedController::class, 'destroy'])->name('coordinator.IvOrganised.destroy');
|
||||||
});
|
});
|
||||||
|
|
||||||
// Faculty routes
|
// Faculty routes
|
||||||
@@ -101,6 +119,14 @@ Route::middleware(['auth', CheckRole::class . ':Faculty'])->group(function () {
|
|||||||
Route::get('/faculty/ActivitiesOrganisedResponses/data', [ActivitiesOrganisedController::class, 'getActivitiesOrganisedResponses'])->name('faculty.ActivitiesOrganisedResponses.data');
|
Route::get('/faculty/ActivitiesOrganisedResponses/data', [ActivitiesOrganisedController::class, 'getActivitiesOrganisedResponses'])->name('faculty.ActivitiesOrganisedResponses.data');
|
||||||
Route::get('/faculty/activities-organised/{id}/edit', [ActivitiesOrganisedController::class, 'edit'])->name('faculty.ActivitiesOrganised.edit');
|
Route::get('/faculty/activities-organised/{id}/edit', [ActivitiesOrganisedController::class, 'edit'])->name('faculty.ActivitiesOrganised.edit');
|
||||||
Route::put('/faculty/activities-organised/{id}', [ActivitiesOrganisedController::class, 'update'])->name('faculty.ActivitiesOrganised.update');
|
Route::put('/faculty/activities-organised/{id}', [ActivitiesOrganisedController::class, 'update'])->name('faculty.ActivitiesOrganised.update');
|
||||||
|
|
||||||
|
// Iv Organised Routes
|
||||||
|
Route::get('/faculty/IvOrganisedForm', [FacultyController::class, 'IvOrganisedForm'])->name('faculty.IvOrganisedForm');
|
||||||
|
Route::post('/faculty/IvOrganisedFormResponse', [FacultyController::class, 'IvOrganisedFormResponse'])->name('faculty.IvOrganisedFormResponse');
|
||||||
|
Route::get('/faculty/IvOrganisedResponses', [FacultyController::class, 'viewIvOrganisedResponses'])->name('faculty.IvOrganisedResponses');
|
||||||
|
Route::get('/faculty/IvOrganisedResponses/data', [IvOrganisedController::class, 'getIvOrganisedResponses'])->name('faculty.IvOrganisedResponses.data');
|
||||||
|
Route::get('/faculty/iv-organised/{id}/edit', [IvOrganisedController::class, 'edit'])->name('faculty.IvOrganised.edit');
|
||||||
|
Route::put('/faculty/iv-organised/{id}', [IvOrganisedController::class, 'update'])->name('faculty.IvOrganised.update');
|
||||||
});
|
});
|
||||||
|
|
||||||
// API Resources
|
// API Resources
|
||||||
|
|||||||
Reference in New Issue
Block a user