diff --git a/app/Infrastructure/Http/Controllers/DashboardController.php b/app/Infrastructure/Http/Controllers/DashboardController.php index 4dda8e2..053fcf4 100644 --- a/app/Infrastructure/Http/Controllers/DashboardController.php +++ b/app/Infrastructure/Http/Controllers/DashboardController.php @@ -66,6 +66,16 @@ class DashboardController extends Controller ) ->count(); + $onRequest = $request->user() + ->vacations() + ->whereRelation( + "vacationRequest", + fn(Builder $query) => $query + ->where("type", VacationType::OnRequest) + ->states(VacationRequestState::successStates()), + ) + ->count(); + $pending = $request->user() ->vacations() ->whereRelation( @@ -96,6 +106,7 @@ class DashboardController extends Controller "used" => $used, "pending" => $pending, "other" => $other, + "onRequest" => 4 - $onRequest, ], ]); } diff --git a/database/seeders/DemoSeeder.php b/database/seeders/DemoSeeder.php index 5f96ff7..4b210c7 100644 --- a/database/seeders/DemoSeeder.php +++ b/database/seeders/DemoSeeder.php @@ -146,8 +146,8 @@ class DemoSeeder extends Seeder $currentYearPeriod = YearPeriod::query()->where("year", 2022)->first(); - /** @var VacationRequest $vacationRequest */ - $vacationRequest = VacationRequest::factory([ + /** @var VacationRequest $vacationRequestApproved */ + $vacationRequestApproved = VacationRequest::factory([ "type" => VacationType::Vacation->value, "state" => VacationRequestState::Created, "from" => Carbon::create($currentYearPeriod->year, 1, 31)->toDateString(), @@ -177,43 +177,149 @@ class DemoSeeder extends Seeder VacationRequestActivity::factory([ "from" => null, "to" => VacationRequestState::Created, - ])->for($vacationRequest) + ])->for($vacationRequestApproved) ->for($employee1) ->create(); VacationRequestActivity::factory([ "from" => VacationRequestState::Created, "to" => VacationRequestState::WaitingForTechnical, - ])->for($vacationRequest) + ])->for($vacationRequestApproved) ->create(); VacationRequestActivity::factory([ "from" => VacationRequestState::WaitingForTechnical, "to" => VacationRequestState::AcceptedByTechnical, - ])->for($vacationRequest) + ])->for($vacationRequestApproved) ->for($technicalApprover) ->create(); VacationRequestActivity::factory([ "from" => VacationRequestState::AcceptedByTechnical, "to" => VacationRequestState::WaitingForAdministrative, - ])->for($vacationRequest) + ])->for($vacationRequestApproved) ->create(); VacationRequestActivity::factory([ "from" => VacationRequestState::WaitingForAdministrative, "to" => VacationRequestState::AcceptedByAdministrative, - ])->for($vacationRequest) + ])->for($vacationRequestApproved) ->for($administrativeApprover) ->create(); VacationRequestActivity::factory([ "from" => VacationRequestState::AcceptedByAdministrative, "to" => VacationRequestState::Approved, - ])->for($vacationRequest) + ])->for($vacationRequestApproved) ->create(); - $vacationRequest->changeStateTo(VacationRequestState::Approved); + $vacationRequestApproved->changeStateTo(VacationRequestState::Approved); + + /** @var VacationRequest $vacationRequestWaitsForAdminApproval */ + $vacationRequestWaitsForAdminApproval = VacationRequest::factory([ + "type" => VacationType::Vacation->value, + "state" => VacationRequestState::Created, + "from" => Carbon::create($currentYearPeriod->year, 2, 14)->toDateString(), + "to" => Carbon::create($currentYearPeriod->year, 2, 14)->toDateString(), + "comment" => "Komentarz do wniosku urlopowego.", + ]) + ->for($employee1) + ->for($employee1, "creator") + ->for($currentYearPeriod) + ->afterCreating(function (VacationRequest $vacationRequest): void { + $days = app(VacationDaysCalculator::class)->calculateDays( + $vacationRequest->yearPeriod, + $vacationRequest->from, + $vacationRequest->to, + ); + + foreach ($days as $day) { + $vacationRequest->vacations()->create([ + "date" => $day, + "user_id" => $vacationRequest->user->id, + "year_period_id" => $vacationRequest->yearPeriod->id, + ]); + } + }) + ->create(); + + VacationRequestActivity::factory([ + "from" => null, + "to" => VacationRequestState::Created, + ])->for($vacationRequestWaitsForAdminApproval) + ->for($employee1) + ->create(); + + VacationRequestActivity::factory([ + "from" => VacationRequestState::Created, + "to" => VacationRequestState::WaitingForTechnical, + ])->for($vacationRequestWaitsForAdminApproval) + ->create(); + + VacationRequestActivity::factory([ + "from" => VacationRequestState::WaitingForTechnical, + "to" => VacationRequestState::AcceptedByTechnical, + ])->for($vacationRequestWaitsForAdminApproval) + ->for($technicalApprover) + ->create(); + + VacationRequestActivity::factory([ + "from" => VacationRequestState::AcceptedByTechnical, + "to" => VacationRequestState::WaitingForAdministrative, + ])->for($vacationRequestWaitsForAdminApproval) + ->create(); + + $vacationRequestWaitsForAdminApproval->changeStateTo(VacationRequestState::WaitingForAdministrative); + + /** @var VacationRequest $vacationRequestRejected */ + $vacationRequestRejected = VacationRequest::factory([ + "type" => VacationType::Vacation->value, + "state" => VacationRequestState::Created, + "from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(), + "to" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(), + "comment" => "", + ]) + ->for($employee1) + ->for($employee1, "creator") + ->for($currentYearPeriod) + ->afterCreating(function (VacationRequest $vacationRequest): void { + $days = app(VacationDaysCalculator::class)->calculateDays( + $vacationRequest->yearPeriod, + $vacationRequest->from, + $vacationRequest->to, + ); + + foreach ($days as $day) { + $vacationRequest->vacations()->create([ + "date" => $day, + "user_id" => $vacationRequest->user->id, + "year_period_id" => $vacationRequest->yearPeriod->id, + ]); + } + }) + ->create(); + + VacationRequestActivity::factory([ + "from" => null, + "to" => VacationRequestState::Created, + ])->for($vacationRequestRejected) + ->for($employee1) + ->create(); + + VacationRequestActivity::factory([ + "from" => VacationRequestState::Created, + "to" => VacationRequestState::WaitingForTechnical, + ])->for($vacationRequestRejected) + ->create(); + + VacationRequestActivity::factory([ + "from" => VacationRequestState::WaitingForTechnical, + "to" => VacationRequestState::Rejected, + ])->for($vacationRequestRejected) + ->for($technicalApprover) + ->create(); + + $vacationRequestRejected->changeStateTo(VacationRequestState::Rejected); } protected function generateAvatarsForUsers(Collection $users): void diff --git a/resources/js/Pages/Dashboard.vue b/resources/js/Pages/Dashboard.vue index 62f9576..ffca69f 100644 --- a/resources/js/Pages/Dashboard.vue +++ b/resources/js/Pages/Dashboard.vue @@ -38,36 +38,70 @@
-
- Limit urlopów -
-
- {{ stats.limit }} -
-
-
-
- Dni do wykorzystania -
-
+
{{ stats.remaining }}
+
+ Pozostało +
+
+ Dni do wykorzystania teraz. +
-
- Dni wykorzystane -
-
+
{{ stats.used }}
+
+ Dni wykorzystane +
+
+ Dni, które zostały już wykorzystane na urlop wypoczynkowy. +
-
- Inne urlopy +
+ {{ stats.pending }}
-
- {{ stats.other }} +
+ Rozpatrywane
+
+ Dni czekające na akceptację przełożonych +
+
+
+
+ {{ stats.limit }} +
+
+ Limit urlopu +
+
+ Twój roczny limit urlopu wypoczynkowego. +
+
+
+
+ {{ stats.onRequest }} +
+
+ Urlop na żądanie +
+
+ Ilość dni urlopu na żądanie, który wlicza się w limit urlopu wypoczynkowego. +
+
+
+
+ {{ stats.other }} +
+
+ Inne urlopy +
+
+ Urlopy bezpłatne, okolicznościowe, zwolnienia lekarskie, itd., które zostały już zatwierdzone. +
diff --git a/resources/js/Shared/MainMenu.vue b/resources/js/Shared/MainMenu.vue index 28f501c..7e91e3b 100644 --- a/resources/js/Shared/MainMenu.vue +++ b/resources/js/Shared/MainMenu.vue @@ -110,7 +110,7 @@ :class="[$page.url === '/' ? 'bg-blumilk-800 text-white' : 'text-blumilk-100 hover:text-white hover:bg-blumilk-600', 'group flex items-center px-2 py-2 text-sm leading-6 font-medium rounded-md']" > - Dashboard + Strona główna