diff --git a/Modules/Attendance/app/Http/Controllers/AttendanceController.php b/Modules/Attendance/app/Http/Controllers/AttendanceController.php index 787a2b0..4f5e59a 100644 --- a/Modules/Attendance/app/Http/Controllers/AttendanceController.php +++ b/Modules/Attendance/app/Http/Controllers/AttendanceController.php @@ -6,15 +6,24 @@ use App\Http\Controllers\Controller; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; use Illuminate\Http\Response; +use Modules\Attendance\Repositories\AttendanceRepository; class AttendanceController extends Controller { + private $attendanceRepository; + + public function __construct(AttendanceRepository $attendanceRepository) + { + $this->attendanceRepository = $attendanceRepository; + } /** * Display a listing of the resource. */ public function index() { - return view('attendance::index'); + $data['title'] = 'Attendance Lists'; + $data['attendanceLists'] = $this->attendanceRepository->findAll(); + return view('attendance::attendances.index', $data); } /** @@ -22,7 +31,9 @@ class AttendanceController extends Controller */ public function create() { - return view('attendance::create'); + $data['title'] = 'Create Attendance'; + $data['editable'] = false; + return view('attendance::attendances.create', $data); } /** @@ -30,7 +41,17 @@ class AttendanceController extends Controller */ public function store(Request $request): RedirectResponse { - // + $request->merge([ + 'date' => $request->date ? $request->date : now()->format('Y-m-d'), + ]); + + try { + $this->attendanceRepository->create($request->all()); + toastr()->success('Attendance Created Successfully'); + } catch (\Throwable $th) { + toastr()->error($th->getMessage()); + } + return redirect()->route('attendance.index'); } /** @@ -38,7 +59,7 @@ class AttendanceController extends Controller */ public function show($id) { - return view('attendance::show'); + return view('attendance::attendances.show'); } /** @@ -46,7 +67,17 @@ class AttendanceController extends Controller */ public function edit($id) { - return view('attendance::edit'); + try { + $data['title'] = 'Edit Attendance'; + $data['editable'] = true; + $data['attendance'] = $this->attendanceRepository->getAttendanceById($id); + + } catch (\Throwable $th) { + toastr()->error($th->getMessage()); + } + + return view('attendance::attendances.edit', $data); + } /** @@ -54,7 +85,15 @@ class AttendanceController extends Controller */ public function update(Request $request, $id): RedirectResponse { - // + try { + + $this->attendanceRepository->update($id, $request->all()); + toastr()->success('Attendance Updated Successfully'); + + } catch (\Throwable $th) { + toastr()->error($th->getMessage()); + } + return redirect()->route('attendance.index'); } /** @@ -62,6 +101,12 @@ class AttendanceController extends Controller */ public function destroy($id) { - // + try { + $this->attendanceRepository->delete($id); + toastr()->success('Attendance Deleted Successfully'); + } catch (\Throwable $th) { + toastr()->error($th->getMessage()); + } + return redirect()->route('attendance.index'); } } diff --git a/Modules/Attendance/app/Models/Attendance.php b/Modules/Attendance/app/Models/Attendance.php new file mode 100644 index 0000000..71b8d20 --- /dev/null +++ b/Modules/Attendance/app/Models/Attendance.php @@ -0,0 +1,30 @@ +update($newDetails); + } + +} diff --git a/Modules/Attendance/database/migrations/2024_04_16_061010_create_attendances_table.php b/Modules/Attendance/database/migrations/2024_04_16_061010_create_attendances_table.php new file mode 100644 index 0000000..9dc1c12 --- /dev/null +++ b/Modules/Attendance/database/migrations/2024_04_16_061010_create_attendances_table.php @@ -0,0 +1,37 @@ +unsignedTinyInteger('attendance_id')->autoIncrement(); + $table->unsignedBigInteger('employee_id')->nullable(); + $table->time('clock_in_time')->nullable(); + $table->time('clock_out_time')->nullable(); + $table->string('work_from_type')->nullable(); + $table->date('date')->nullable(); + $table->integer('status')->nullable(); + $table->integer('total_hours')->nullable(); + $table->mediumText('description')->nullable(); + $table->mediumText('remarks')->nullable(); + $table->unsignedBigInteger('createdBy')->nullable(); + $table->unsignedBigInteger('updatedBy')->nullable(); + $table->timestamps(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('tbl_attendances'); + } +}; diff --git a/Modules/Attendance/resources/views/attendances/create.blade.php b/Modules/Attendance/resources/views/attendances/create.blade.php new file mode 100644 index 0000000..71cb915 --- /dev/null +++ b/Modules/Attendance/resources/views/attendances/create.blade.php @@ -0,0 +1,23 @@ +@extends('layouts.app') +@section('content') +
+
+ + + @include('layouts.partials.breadcrumb', ['title' => $title]) + + + +
+
+ + {{ html()->form('POST')->route('attendance.store')->class(['needs-validation'])->attributes(['novalidate'])->open() }} + + @include('attendance::partials.attendances.action') + + {{ html()->form()->close() }} + +
+
+
+ @endsection diff --git a/Modules/Attendance/resources/views/attendances/edit.blade.php b/Modules/Attendance/resources/views/attendances/edit.blade.php new file mode 100644 index 0000000..10a8784 --- /dev/null +++ b/Modules/Attendance/resources/views/attendances/edit.blade.php @@ -0,0 +1,23 @@ +@extends('layouts.app') +@section('content') +
+
+ + + @include('layouts.partials.breadcrumb', ['title' => $title]) + + + +
+
+ + {{ html()->modelForm($attendance, 'PUT')->route('attendance.update', $attendance->attendance_id)->class(['needs-validation'])->attributes(['novalidate'])->open() }} + + @include('attendance::partials.attendances.action') + + {{ html()->form()->close() }} + +
+
+
+ @endsection diff --git a/Modules/Attendance/resources/views/attendances/index.blade.php b/Modules/Attendance/resources/views/attendances/index.blade.php new file mode 100644 index 0000000..9287621 --- /dev/null +++ b/Modules/Attendance/resources/views/attendances/index.blade.php @@ -0,0 +1,238 @@ +@extends('layouts.app') +@section('content') +
+
+ + + @include('layouts.partials.breadcrumb', ['title' => $title]) + + + +
+
+
{{ $title }}
+ +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Employee1 +
+ + Mon + +
2 +
+ + Tue + +
3 +
+ + Wed + +
4 +
+ + Thu + +
5 +
+ + Fri + +
6 +
+ + Sat + +
7 +
+ + Sun + +
8 +
+ + Mon + +
9 +
+ + Tue + +
10 +
+ + Wed + +
11 +
+ + Thu + +
12 +
+ + Fri + +
13 +
+ + Sat + +
14 +
+ + Sun + +
15 +
+ + Mon + +
16 +
+ + Tue + +
17 +
+ + Wed + +
18 +
+ + Thu + +
19 +
+ + Fri + +
20 +
+ + Sat + +
21 +
+ + Sun + +
22 +
+ + Mon + +
23 +
+ + Tue + +
24 +
+ + Wed + +
25 +
+ + Thu + +
26 +
+ + Fri + +
27 +
+ + Sat + +
28 +
+ + Sun + +
29 +
+ + Mon + +
30 +
+ + Tue + +
Total
+
+
+
+ Mr. + Fletcher Berge It's you +
+

+ Junior +

+
+
+
+ 0 / 30
+
+
+
+
+
+
+
+@endsection diff --git a/Modules/Attendance/resources/views/partials/attendances/action.blade.php b/Modules/Attendance/resources/views/partials/attendances/action.blade.php new file mode 100644 index 0000000..1541640 --- /dev/null +++ b/Modules/Attendance/resources/views/partials/attendances/action.blade.php @@ -0,0 +1,32 @@ +
+ +
+ {{ html()->label('Employee')->class('form-label') }} + {{ html()->select('employee_id')->class('form-select')->placeholder('Select Employee') }} +
+ +
+ {{ html()->label('Clock In')->class('form-label') }} + {{ html()->time('clock_in_time')->class('form-control') }} +
+ + +
+ {{ html()->label('Clock Out')->class('form-label') }} + {{ html()->time('clock_out_time')->class('form-control') }} +
+ +
+ {{ html()->label('Date')->class('form-label') }} + {{ html()->date('date')->class('form-control')->placeholder('Attendance Date') }} +
+ +
+ {{ html()->label('Working From')->class('form-label') }} + {{ html()->select('work_from_type', ['home' => 'Home', 'office' => 'Office', 'other' => 'Other'])->class('form-select')->placeholder('Working From') }} +
+ +
+ {{ html()->button($editable ? 'Update' : 'Mark Attendance', 'submit')->class('btn btn-success') }} +
+
diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index 207efc3..e9ace00 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -110,7 +110,7 @@ {{-- --}} - + @@ -123,7 +123,9 @@ - + + + diff --git a/resources/views/layouts/partials/sidebar.blade.php b/resources/views/layouts/partials/sidebar.blade.php index a94b589..1aa186c 100644 --- a/resources/views/layouts/partials/sidebar.blade.php +++ b/resources/views/layouts/partials/sidebar.blade.php @@ -39,6 +39,7 @@ aria-controls="MenuOne"> Company Setup + + + + + Calendar + +