All pages updated with all features including filters
This commit is contained in:
84
app/DataTables/ActivitiesOrganisedDataTable.php
Normal file
84
app/DataTables/ActivitiesOrganisedDataTable.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
|
||||
use App\Models\ActivitiesOrganised;
|
||||
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
|
||||
use Yajra\DataTables\EloquentDataTable;
|
||||
use Yajra\DataTables\Html\Builder as HtmlBuilder;
|
||||
use Yajra\DataTables\Html\Button;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use Yajra\DataTables\Html\Editor\Editor;
|
||||
use Yajra\DataTables\Html\Editor\Fields;
|
||||
use Yajra\DataTables\Services\DataTable;
|
||||
|
||||
class ActivitiesOrganisedDataTable extends DataTable
|
||||
{
|
||||
/**
|
||||
* Build the DataTable class.
|
||||
*
|
||||
* @param QueryBuilder $query Results from query() method.
|
||||
*/
|
||||
public function dataTable(QueryBuilder $query): EloquentDataTable
|
||||
{
|
||||
return (new EloquentDataTable($query))
|
||||
->addColumn('action', 'activitiesorganised.action')
|
||||
->setRowId('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the query source of dataTable.
|
||||
*/
|
||||
public function query(ActivitiesOrganised $model): QueryBuilder
|
||||
{
|
||||
return $model->newQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional method if you want to use the html builder.
|
||||
*/
|
||||
public function html(): HtmlBuilder
|
||||
{
|
||||
return $this->builder()
|
||||
->setTableId('activitiesorganised-table')
|
||||
->columns($this->getColumns())
|
||||
->minifiedAjax()
|
||||
//->dom('Bfrtip')
|
||||
->orderBy(1)
|
||||
->selectStyleSingle()
|
||||
->buttons([
|
||||
Button::make('excel'),
|
||||
Button::make('csv'),
|
||||
Button::make('pdf'),
|
||||
Button::make('print'),
|
||||
Button::make('reset'),
|
||||
Button::make('reload')
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the dataTable columns definition.
|
||||
*/
|
||||
public function getColumns(): array
|
||||
{
|
||||
return [
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(60)
|
||||
->addClass('text-center'),
|
||||
Column::make('id'),
|
||||
Column::make('add your columns'),
|
||||
Column::make('created_at'),
|
||||
Column::make('updated_at'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filename for export.
|
||||
*/
|
||||
protected function filename(): string
|
||||
{
|
||||
return 'ActivitiesOrganised_' . date('YmdHis');
|
||||
}
|
||||
}
|
||||
84
app/DataTables/BooksPublishedDataTable.php
Normal file
84
app/DataTables/BooksPublishedDataTable.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
|
||||
use App\Models\BooksPublished;
|
||||
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
|
||||
use Yajra\DataTables\EloquentDataTable;
|
||||
use Yajra\DataTables\Html\Builder as HtmlBuilder;
|
||||
use Yajra\DataTables\Html\Button;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use Yajra\DataTables\Html\Editor\Editor;
|
||||
use Yajra\DataTables\Html\Editor\Fields;
|
||||
use Yajra\DataTables\Services\DataTable;
|
||||
|
||||
class BooksPublishedDataTable extends DataTable
|
||||
{
|
||||
/**
|
||||
* Build the DataTable class.
|
||||
*
|
||||
* @param QueryBuilder $query Results from query() method.
|
||||
*/
|
||||
public function dataTable(QueryBuilder $query): EloquentDataTable
|
||||
{
|
||||
return (new EloquentDataTable($query))
|
||||
->addColumn('action', 'bookspublished.action')
|
||||
->setRowId('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the query source of dataTable.
|
||||
*/
|
||||
public function query(BooksPublished $model): QueryBuilder
|
||||
{
|
||||
return $model->newQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional method if you want to use the html builder.
|
||||
*/
|
||||
public function html(): HtmlBuilder
|
||||
{
|
||||
return $this->builder()
|
||||
->setTableId('bookspublished-table')
|
||||
->columns($this->getColumns())
|
||||
->minifiedAjax()
|
||||
//->dom('Bfrtip')
|
||||
->orderBy(1)
|
||||
->selectStyleSingle()
|
||||
->buttons([
|
||||
Button::make('excel'),
|
||||
Button::make('csv'),
|
||||
Button::make('pdf'),
|
||||
Button::make('print'),
|
||||
Button::make('reset'),
|
||||
Button::make('reload')
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the dataTable columns definition.
|
||||
*/
|
||||
public function getColumns(): array
|
||||
{
|
||||
return [
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(60)
|
||||
->addClass('text-center'),
|
||||
Column::make('id'),
|
||||
Column::make('add your columns'),
|
||||
Column::make('created_at'),
|
||||
Column::make('updated_at'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filename for export.
|
||||
*/
|
||||
protected function filename(): string
|
||||
{
|
||||
return 'BooksPublished_' . date('YmdHis');
|
||||
}
|
||||
}
|
||||
84
app/DataTables/IndustrialVisitOrganisedDataTable.php
Normal file
84
app/DataTables/IndustrialVisitOrganisedDataTable.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataTables;
|
||||
|
||||
use App\Models\IndustrialVisitOrganised;
|
||||
use Illuminate\Database\Eloquent\Builder as QueryBuilder;
|
||||
use Yajra\DataTables\EloquentDataTable;
|
||||
use Yajra\DataTables\Html\Builder as HtmlBuilder;
|
||||
use Yajra\DataTables\Html\Button;
|
||||
use Yajra\DataTables\Html\Column;
|
||||
use Yajra\DataTables\Html\Editor\Editor;
|
||||
use Yajra\DataTables\Html\Editor\Fields;
|
||||
use Yajra\DataTables\Services\DataTable;
|
||||
|
||||
class IndustrialVisitOrganisedDataTable extends DataTable
|
||||
{
|
||||
/**
|
||||
* Build the DataTable class.
|
||||
*
|
||||
* @param QueryBuilder $query Results from query() method.
|
||||
*/
|
||||
public function dataTable(QueryBuilder $query): EloquentDataTable
|
||||
{
|
||||
return (new EloquentDataTable($query))
|
||||
->addColumn('action', 'industrialvisitorganised.action')
|
||||
->setRowId('id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the query source of dataTable.
|
||||
*/
|
||||
public function query(IndustrialVisitOrganised $model): QueryBuilder
|
||||
{
|
||||
return $model->newQuery();
|
||||
}
|
||||
|
||||
/**
|
||||
* Optional method if you want to use the html builder.
|
||||
*/
|
||||
public function html(): HtmlBuilder
|
||||
{
|
||||
return $this->builder()
|
||||
->setTableId('industrialvisitorganised-table')
|
||||
->columns($this->getColumns())
|
||||
->minifiedAjax()
|
||||
//->dom('Bfrtip')
|
||||
->orderBy(1)
|
||||
->selectStyleSingle()
|
||||
->buttons([
|
||||
Button::make('excel'),
|
||||
Button::make('csv'),
|
||||
Button::make('pdf'),
|
||||
Button::make('print'),
|
||||
Button::make('reset'),
|
||||
Button::make('reload')
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the dataTable columns definition.
|
||||
*/
|
||||
public function getColumns(): array
|
||||
{
|
||||
return [
|
||||
Column::computed('action')
|
||||
->exportable(false)
|
||||
->printable(false)
|
||||
->width(60)
|
||||
->addClass('text-center'),
|
||||
Column::make('id'),
|
||||
Column::make('add your columns'),
|
||||
Column::make('created_at'),
|
||||
Column::make('updated_at'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the filename for export.
|
||||
*/
|
||||
protected function filename(): string
|
||||
{
|
||||
return 'IndustrialVisitOrganised_' . date('YmdHis');
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ class BooksPublishedController extends Controller
|
||||
return response()->json(['success' => 'Publication deleted successfully']);
|
||||
}
|
||||
|
||||
public function getBooksPublishedResponses()
|
||||
public function getBooksPublishedResponses(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$isAdmin = $user->role->name === 'Admin';
|
||||
@@ -127,6 +127,21 @@ class BooksPublishedController extends Controller
|
||||
->where('faculty_id', $user->id);
|
||||
}
|
||||
|
||||
// Apply filters
|
||||
if ($request->has('department_id') && !empty($request->department_id)) {
|
||||
$booksPublisheds->whereHas('department', function ($query) use ($request) {
|
||||
$query->where('id', $request->department_id);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->has('publisher') && !empty($request->publisher)) {
|
||||
$booksPublisheds->where('publisher', $request->publisher);
|
||||
}
|
||||
|
||||
if ($request->has('date_of_publication') && !empty($request->date_of_publication)) {
|
||||
$booksPublisheds->where('date_of_publication', $request->date_of_publication);
|
||||
}
|
||||
|
||||
return DataTables::of($booksPublisheds)
|
||||
->addColumn('user_name', function ($booksPublished) {
|
||||
return $booksPublished->user->name ?? 'Unknown';
|
||||
@@ -149,14 +164,26 @@ class BooksPublishedController extends Controller
|
||||
->addColumn('date_of_publication', function ($booksPublished) {
|
||||
return \Carbon\Carbon::parse($booksPublished->date_of_publication)->format('d-m-Y');
|
||||
})
|
||||
->filterColumn('user_name', function($query, $keyword) {
|
||||
$query->whereHas('user', fn($q) => $q->where('name', 'like', "%{$keyword}%"));
|
||||
})
|
||||
->filterColumn('author', fn($query, $keyword) =>
|
||||
$query->where('author', 'like', "%{$keyword}%")
|
||||
)
|
||||
->filterColumn('title', fn($query, $keyword) =>
|
||||
$query->where('title', 'like', "%{$keyword}%")
|
||||
)
|
||||
->filterColumn('issn', fn($query, $keyword) =>
|
||||
$query->where('issn', 'like', "%{$keyword}%")
|
||||
)
|
||||
->addColumn('action', function ($booksPublished) {
|
||||
$actions = [];
|
||||
|
||||
// View proof button for everyone
|
||||
if ($booksPublished->proof) {
|
||||
$actions[] = '<a href="' . asset('storage/' . $booksPublished->proof) . '" target="_blank" class="btn btn-sm btn-primary mr-1">View</a>';
|
||||
$actions[] = '<a href="' . asset('storage/' . $booksPublished->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
|
||||
@@ -170,10 +197,10 @@ class BooksPublishedController extends Controller
|
||||
$editRoute = route('faculty.BooksPublished.edit', $booksPublished->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('booksPublished.destroy', $booksPublished->id);
|
||||
$actions[] = '<button type="button" class="btn btn-sm btn-danger delete-btn" data-id="' . $booksPublished->id . '" data-url="' . $deleteRoute . '">Delete</button>';
|
||||
$actions[] = '<button type="button" class="btn btn-sm btn-danger delete-btn" data-id="' . $booksPublished->id . '" data-url="' . $deleteRoute . '"><i class="fas fa-trash"></i></button>';
|
||||
|
||||
return implode(' ', $actions);
|
||||
})
|
||||
|
||||
@@ -31,6 +31,10 @@ class ExternalEngagementController extends Controller
|
||||
'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
|
||||
@@ -94,7 +98,7 @@ class ExternalEngagementController extends Controller
|
||||
return response()->json(['success' => 'External Engagement record deleted successfully']);
|
||||
}
|
||||
|
||||
public function getExternalEngagementResponses()
|
||||
public function getExternalEngagementResponses(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$isAdmin = $user->role->name === 'Admin';
|
||||
@@ -116,6 +120,24 @@ class ExternalEngagementController extends Controller
|
||||
->where('faculty_id', $user->id);
|
||||
}
|
||||
|
||||
// Apply filters
|
||||
if ($request->has('department') && !empty($request->department)) {
|
||||
$externalEngagements->whereHas('department', function ($query) use ($request) {
|
||||
$query->where('id', $request->department);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->has('activity') && !empty($request->activity)) {
|
||||
$externalEngagements->where('activity', $request->activity);
|
||||
}
|
||||
|
||||
if ($request->has('dateFrom') && !empty($request->dateFrom)) {
|
||||
$externalEngagements->where('start_date', '>=', $request->dateFrom);
|
||||
}
|
||||
|
||||
if ($request->has('dateTo') && !empty($request->dateTo)) {
|
||||
$externalEngagements->where('end_date', '<=', $request->dateTo);
|
||||
}
|
||||
|
||||
return DataTables::of($externalEngagements)
|
||||
->addColumn('user_name', function ($externalEngagement) {
|
||||
@@ -142,6 +164,20 @@ class ExternalEngagementController extends Controller
|
||||
->addColumn('num_days', function ($externalEngagement) {
|
||||
return $externalEngagement->num_days ?? 'Unknown';
|
||||
})
|
||||
->filterColumn('user_name', function($query, $keyword) {
|
||||
$query->whereHas('user', function($q) use ($keyword) {
|
||||
$q->where('name', 'like', "%{$keyword}%");
|
||||
});
|
||||
})
|
||||
->filterColumn('activity_description', function($query, $keyword) {
|
||||
$query->where('activity_description', 'like', "%{$keyword}%");
|
||||
})
|
||||
->filterColumn('inviting_organization', function($query, $keyword) {
|
||||
$query->where('inviting_organization', 'like', "%{$keyword}%");
|
||||
})
|
||||
->filterColumn('num_days', function($query, $keyword) {
|
||||
$query->where('num_days', 'like', "%{$keyword}%");
|
||||
})
|
||||
->addColumn('action', function ($externalEngagement) {
|
||||
$actions = [];
|
||||
|
||||
@@ -149,7 +185,7 @@ class ExternalEngagementController extends Controller
|
||||
if ($externalEngagement->proof) {
|
||||
$actions[] = '<a href="' . asset('storage/' . $externalEngagement->proof) . '" target="_blank" class="btn btn-sm btn-primary mr-1">View</a>';
|
||||
} else {
|
||||
$actions[] = 'No Proof';
|
||||
$actions[] = '<span class="text-muted"><i class="fas fa-times-circle"></i></span>';
|
||||
}
|
||||
|
||||
// Edit button with role-appropriate route
|
||||
@@ -163,10 +199,10 @@ class ExternalEngagementController extends Controller
|
||||
$editRoute = route('faculty.ExternalEngagement.edit', $externalEngagement->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('externalEngagement.destroy', $externalEngagement->id);
|
||||
$actions[] = '<button type="button" class="btn btn-sm btn-danger delete-btn" data-id="' . $externalEngagement->id . '" data-url="' . $deleteRoute . '">Delete</button>';
|
||||
$actions[] = '<button type="button" class="btn btn-sm btn-danger delete-btn" data-id="' . $externalEngagement->id . '" data-url="' . $deleteRoute . '"><i class="fas fa-trash"></i></button>';
|
||||
|
||||
return implode(' ', $actions);
|
||||
})
|
||||
|
||||
@@ -52,6 +52,7 @@ class IvOrganisedController extends Controller
|
||||
// Extract year from start_date
|
||||
$year = date('Y', strtotime($validated['start_date']));
|
||||
$username = $response->user->name;
|
||||
$userId = $response->user->id;
|
||||
|
||||
$originalName = $request->file('proof')->getClientOriginalName();
|
||||
$fileName = $username . '_' . $originalName;
|
||||
@@ -109,12 +110,12 @@ class IvOrganisedController extends Controller
|
||||
return response()->json(['success' => 'Industrial visit record deleted successfully']);
|
||||
}
|
||||
|
||||
public function getIvOrganisedResponses()
|
||||
public function getIvOrganisedResponses(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$isAdmin = $user->role->name === 'Admin';
|
||||
$isCoordinator = $user->role->name === 'Coordinator';
|
||||
|
||||
|
||||
// Query based on role
|
||||
if ($isAdmin) {
|
||||
// Admin sees all records
|
||||
@@ -131,6 +132,25 @@ class IvOrganisedController 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('target_audience') && !empty($request->target_audience)) {
|
||||
$responses->where('target_audience', $request->target_audience);
|
||||
}
|
||||
|
||||
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';
|
||||
@@ -157,7 +177,7 @@ class IvOrganisedController extends Controller
|
||||
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';
|
||||
$actions[] = '<span class="text-muted"><i class="fas fa-times-circle"></i></span>';
|
||||
}
|
||||
|
||||
// Edit button with role-appropriate route
|
||||
@@ -171,10 +191,10 @@ class IvOrganisedController extends Controller
|
||||
$editRoute = route('faculty.IvOrganised.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('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>';
|
||||
$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);
|
||||
})
|
||||
@@ -201,7 +221,7 @@ class IvOrganisedController extends Controller
|
||||
'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',
|
||||
'proof' => 'nullable|mimes:jpg,jpeg,png,pdf,doc,docx,zip',
|
||||
]);
|
||||
|
||||
// Combine start date and time
|
||||
|
||||
@@ -30,6 +30,10 @@ class OnlineCoursesController extends Controller
|
||||
'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
|
||||
@@ -40,6 +44,7 @@ class OnlineCoursesController extends Controller
|
||||
// Extract year from start_date
|
||||
$year = date('Y', strtotime($validated['start_date']));
|
||||
$username = $onlineCourse->user->name;
|
||||
$userId = $onlineCourse->user->id;
|
||||
|
||||
$originalName = $request->file('proof')->getClientOriginalName();
|
||||
$fileName = $username . '_' . $originalName;
|
||||
@@ -92,7 +97,7 @@ class OnlineCoursesController extends Controller
|
||||
return response()->json(['success' => 'online Course record deleted successfully']);
|
||||
}
|
||||
|
||||
public function getOnlineCoursesResponses()
|
||||
public function getOnlineCoursesResponses(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$isAdmin = $user->role->name === 'Admin';
|
||||
@@ -114,6 +119,24 @@ class OnlineCoursesController extends Controller
|
||||
->where('faculty_id', $user->id);
|
||||
}
|
||||
|
||||
// Apply filters
|
||||
if ($request->has('department') && !empty($request->department)) {
|
||||
$onlineCourses->whereHas('department', function ($query) use ($request) {
|
||||
$query->where('id', $request->department);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->has('offered_by') && !empty($request->offered_by)) {
|
||||
$onlineCourses->where('offered_by', $request->offered_by);
|
||||
}
|
||||
|
||||
if ($request->has('dateFrom') && !empty($request->dateFrom)) {
|
||||
$onlineCourses->where('start_date', '>=', $request->dateFrom);
|
||||
}
|
||||
|
||||
if ($request->has('dateTo') && !empty($request->dateTo)) {
|
||||
$onlineCourses->where('end_date', '<=', $request->dateTo);
|
||||
}
|
||||
|
||||
return DataTables::of($onlineCourses)
|
||||
->addColumn('user_name', function ($onlineCourse) {
|
||||
@@ -122,9 +145,17 @@ class OnlineCoursesController extends Controller
|
||||
->addColumn('department_name', function ($onlineCourse) {
|
||||
return $onlineCourse->department->name ?? 'Unknown';
|
||||
})
|
||||
->filterColumn('user_name', function($query, $keyword) {
|
||||
$query->whereHas('user', function($q) use ($keyword) {
|
||||
$q->where('name', 'like', "%{$keyword}%");
|
||||
});
|
||||
})
|
||||
->addColumn('course', function ($onlineCourse) {
|
||||
return $onlineCourse->course ?? 'Unknown';
|
||||
})
|
||||
->filterColumn('course', function($query, $keyword) {
|
||||
$query->where('course', 'like', "%{$keyword}%");
|
||||
})
|
||||
->addColumn('offered_by', function ($onlineCourse) {
|
||||
return $onlineCourse->offered_by ?? 'Unknown';
|
||||
})
|
||||
@@ -137,14 +168,17 @@ class OnlineCoursesController extends Controller
|
||||
->addColumn('num_days', function ($onlineCourse) {
|
||||
return $onlineCourse->num_days ?? 'Unknown';
|
||||
})
|
||||
->filterColumn('num_days', function($query, $keyword) {
|
||||
$query->where('num_days', 'like', "%{$keyword}%");
|
||||
})
|
||||
->addColumn('action', function ($onlineCourse) {
|
||||
$actions = [];
|
||||
|
||||
// View proof button for everyone
|
||||
if ($onlineCourse->proof) {
|
||||
$actions[] = '<a href="' . asset('storage/' . $onlineCourse->proof) . '" target="_blank" class="btn btn-sm btn-primary mr-1">View</a>';
|
||||
$actions[] = '<a href="' . asset('storage/' . $onlineCourse->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
|
||||
@@ -158,10 +192,10 @@ class OnlineCoursesController extends Controller
|
||||
$editRoute = route('faculty.OnlineCourses.edit', $onlineCourse->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('onlineCourses.destroy', $onlineCourse->id);
|
||||
$actions[] = '<button type="button" class="btn btn-sm btn-danger delete-btn" data-id="' . $onlineCourse->id . '" data-url="' . $deleteRoute . '">Delete</button>';
|
||||
$actions[] = '<button type="button" class="btn btn-sm btn-danger delete-btn" data-id="' . $onlineCourse->id . '" data-url="' . $deleteRoute . '"><i class="fas fa-trash"></i></button>';
|
||||
|
||||
return implode(' ', $actions);
|
||||
})
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\OnlineCourse;
|
||||
use App\Models\Patent;
|
||||
use Illuminate\Http\Request;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
use App\Models\Patent;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
|
||||
class PatentsController extends Controller
|
||||
@@ -13,8 +12,11 @@ class PatentsController extends Controller
|
||||
public function edit($id)
|
||||
{
|
||||
$patent = Patent::findOrFail($id);
|
||||
$organisingInstitutes = Publication::select('organizing_institute')
|
||||
->distinct()
|
||||
->pluck('organizing_institute');
|
||||
|
||||
return view('pages.patents.edit', compact('patent'));
|
||||
return view('pages.patents.edit', compact('patent', 'organisingInstitutes'));
|
||||
}
|
||||
|
||||
public function update(Request $request, $id)
|
||||
@@ -33,6 +35,10 @@ class PatentsController extends Controller
|
||||
'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
|
||||
@@ -43,6 +49,7 @@ class PatentsController extends Controller
|
||||
// Extract year from start_date
|
||||
$year = date('Y', strtotime($validated['date_of_submission']));
|
||||
$username = $patent->user->name;
|
||||
$userId = $patent->user->id;
|
||||
|
||||
$originalName = $request->file('proof')->getClientOriginalName();
|
||||
$fileName = $username . '_' . $originalName;
|
||||
@@ -97,7 +104,7 @@ class PatentsController extends Controller
|
||||
return response()->json(['success' => 'patent record deleted successfully']);
|
||||
}
|
||||
|
||||
public function getPatentsResponses()
|
||||
public function getPatentsResponses(Request $request)
|
||||
{
|
||||
$user = auth()->user();
|
||||
$isAdmin = $user->role->name === 'Admin';
|
||||
@@ -119,6 +126,24 @@ class PatentsController extends Controller
|
||||
->where('faculty_id', $user->id);
|
||||
}
|
||||
|
||||
// Apply filters
|
||||
if ($request->has('department') && !empty($request->department)) {
|
||||
$patents->whereHas('department', function ($query) use ($request) {
|
||||
$query->where('id', $request->department);
|
||||
});
|
||||
}
|
||||
|
||||
if ($request->has('status') && !empty($request->status)) {
|
||||
$patents->where('status', $request->status);
|
||||
}
|
||||
|
||||
if ($request->has('dateFrom') && !empty($request->dateFrom)) {
|
||||
$patents->where('date_of_submission', '>=', $request->dateFrom);
|
||||
}
|
||||
|
||||
if ($request->has('dateTo') && !empty($request->dateTo)) {
|
||||
$patents->where('date_of_submission', '<=', $request->dateTo);
|
||||
}
|
||||
|
||||
return DataTables::of($patents)
|
||||
->addColumn('user_name', function ($patent) {
|
||||
@@ -148,14 +173,31 @@ class PatentsController extends Controller
|
||||
->addColumn('status', function ($patent) {
|
||||
return $patent->status ?? 'Unknown';
|
||||
})
|
||||
->filterColumn('user_name', function($query, $keyword) {
|
||||
$query->whereHas('user', function($q) use ($keyword) {
|
||||
$q->where('name', 'like', "%{$keyword}%");
|
||||
});
|
||||
})
|
||||
->filterColumn('title', function($query, $keyword) {
|
||||
$query->where('title', 'like', "%{$keyword}%");
|
||||
})
|
||||
->filterColumn('investigator', function($query, $keyword) {
|
||||
$query->where('investigator', 'like', "%{$keyword}%");
|
||||
})
|
||||
->filterColumn('application_no', function($query, $keyword) {
|
||||
$query->where('application_no', 'like', "%{$keyword}%");
|
||||
})
|
||||
->filterColumn('type', function($query, $keyword) {
|
||||
$query->where('type', 'like', "%{$keyword}%");
|
||||
})
|
||||
->addColumn('action', function ($patent) {
|
||||
$actions = [];
|
||||
|
||||
// View proof button for everyone
|
||||
if ($patent->proof) {
|
||||
$actions[] = '<a href="' . asset('storage/' . $patent->proof) . '" target="_blank" class="btn btn-sm btn-primary mr-1">View</a>';
|
||||
$actions[] = '<a href="' . asset('storage/' . $patent->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
|
||||
@@ -169,10 +211,10 @@ class PatentsController extends Controller
|
||||
$editRoute = route('faculty.Patents.edit', $patent->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('patents.destroy', $patent->id);
|
||||
$actions[] = '<button type="button" class="btn btn-sm btn-danger delete-btn" data-id="' . $patent->id . '" data-url="' . $deleteRoute . '">Delete</button>';
|
||||
$actions[] = '<button type="button" class="btn btn-sm btn-danger delete-btn" data-id="' . $patent->id . '" data-url="' . $deleteRoute . '"><i class="fas fa-trash"></i></button>';
|
||||
|
||||
return implode(' ', $actions);
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user