wip
This commit is contained in:
		@@ -66,6 +66,16 @@ class DashboardController extends Controller
 | 
				
			|||||||
            )
 | 
					            )
 | 
				
			||||||
            ->count();
 | 
					            ->count();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $onRequest = $request->user()
 | 
				
			||||||
 | 
					            ->vacations()
 | 
				
			||||||
 | 
					            ->whereRelation(
 | 
				
			||||||
 | 
					                "vacationRequest",
 | 
				
			||||||
 | 
					                fn(Builder $query) => $query
 | 
				
			||||||
 | 
					                    ->where("type", VacationType::OnRequest)
 | 
				
			||||||
 | 
					                    ->states(VacationRequestState::successStates()),
 | 
				
			||||||
 | 
					            )
 | 
				
			||||||
 | 
					            ->count();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $pending = $request->user()
 | 
					        $pending = $request->user()
 | 
				
			||||||
            ->vacations()
 | 
					            ->vacations()
 | 
				
			||||||
            ->whereRelation(
 | 
					            ->whereRelation(
 | 
				
			||||||
@@ -96,6 +106,7 @@ class DashboardController extends Controller
 | 
				
			|||||||
                "used" => $used,
 | 
					                "used" => $used,
 | 
				
			||||||
                "pending" => $pending,
 | 
					                "pending" => $pending,
 | 
				
			||||||
                "other" => $other,
 | 
					                "other" => $other,
 | 
				
			||||||
 | 
					                "onRequest" => 4 - $onRequest,
 | 
				
			||||||
            ],
 | 
					            ],
 | 
				
			||||||
        ]);
 | 
					        ]);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -146,8 +146,8 @@ class DemoSeeder extends Seeder
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        $currentYearPeriod = YearPeriod::query()->where("year", 2022)->first();
 | 
					        $currentYearPeriod = YearPeriod::query()->where("year", 2022)->first();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /** @var VacationRequest $vacationRequest */
 | 
					        /** @var VacationRequest $vacationRequestApproved */
 | 
				
			||||||
        $vacationRequest = VacationRequest::factory([
 | 
					        $vacationRequestApproved = VacationRequest::factory([
 | 
				
			||||||
            "type" => VacationType::Vacation->value,
 | 
					            "type" => VacationType::Vacation->value,
 | 
				
			||||||
            "state" => VacationRequestState::Created,
 | 
					            "state" => VacationRequestState::Created,
 | 
				
			||||||
            "from" => Carbon::create($currentYearPeriod->year, 1, 31)->toDateString(),
 | 
					            "from" => Carbon::create($currentYearPeriod->year, 1, 31)->toDateString(),
 | 
				
			||||||
@@ -177,43 +177,149 @@ class DemoSeeder extends Seeder
 | 
				
			|||||||
        VacationRequestActivity::factory([
 | 
					        VacationRequestActivity::factory([
 | 
				
			||||||
            "from" => null,
 | 
					            "from" => null,
 | 
				
			||||||
            "to" => VacationRequestState::Created,
 | 
					            "to" => VacationRequestState::Created,
 | 
				
			||||||
        ])->for($vacationRequest)
 | 
					        ])->for($vacationRequestApproved)
 | 
				
			||||||
            ->for($employee1)
 | 
					            ->for($employee1)
 | 
				
			||||||
            ->create();
 | 
					            ->create();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        VacationRequestActivity::factory([
 | 
					        VacationRequestActivity::factory([
 | 
				
			||||||
            "from" => VacationRequestState::Created,
 | 
					            "from" => VacationRequestState::Created,
 | 
				
			||||||
            "to" => VacationRequestState::WaitingForTechnical,
 | 
					            "to" => VacationRequestState::WaitingForTechnical,
 | 
				
			||||||
        ])->for($vacationRequest)
 | 
					        ])->for($vacationRequestApproved)
 | 
				
			||||||
            ->create();
 | 
					            ->create();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        VacationRequestActivity::factory([
 | 
					        VacationRequestActivity::factory([
 | 
				
			||||||
            "from" => VacationRequestState::WaitingForTechnical,
 | 
					            "from" => VacationRequestState::WaitingForTechnical,
 | 
				
			||||||
            "to" => VacationRequestState::AcceptedByTechnical,
 | 
					            "to" => VacationRequestState::AcceptedByTechnical,
 | 
				
			||||||
        ])->for($vacationRequest)
 | 
					        ])->for($vacationRequestApproved)
 | 
				
			||||||
            ->for($technicalApprover)
 | 
					            ->for($technicalApprover)
 | 
				
			||||||
            ->create();
 | 
					            ->create();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        VacationRequestActivity::factory([
 | 
					        VacationRequestActivity::factory([
 | 
				
			||||||
            "from" => VacationRequestState::AcceptedByTechnical,
 | 
					            "from" => VacationRequestState::AcceptedByTechnical,
 | 
				
			||||||
            "to" => VacationRequestState::WaitingForAdministrative,
 | 
					            "to" => VacationRequestState::WaitingForAdministrative,
 | 
				
			||||||
        ])->for($vacationRequest)
 | 
					        ])->for($vacationRequestApproved)
 | 
				
			||||||
            ->create();
 | 
					            ->create();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        VacationRequestActivity::factory([
 | 
					        VacationRequestActivity::factory([
 | 
				
			||||||
            "from" => VacationRequestState::WaitingForAdministrative,
 | 
					            "from" => VacationRequestState::WaitingForAdministrative,
 | 
				
			||||||
            "to" => VacationRequestState::AcceptedByAdministrative,
 | 
					            "to" => VacationRequestState::AcceptedByAdministrative,
 | 
				
			||||||
        ])->for($vacationRequest)
 | 
					        ])->for($vacationRequestApproved)
 | 
				
			||||||
            ->for($administrativeApprover)
 | 
					            ->for($administrativeApprover)
 | 
				
			||||||
            ->create();
 | 
					            ->create();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        VacationRequestActivity::factory([
 | 
					        VacationRequestActivity::factory([
 | 
				
			||||||
            "from" => VacationRequestState::AcceptedByAdministrative,
 | 
					            "from" => VacationRequestState::AcceptedByAdministrative,
 | 
				
			||||||
            "to" => VacationRequestState::Approved,
 | 
					            "to" => VacationRequestState::Approved,
 | 
				
			||||||
        ])->for($vacationRequest)
 | 
					        ])->for($vacationRequestApproved)
 | 
				
			||||||
            ->create();
 | 
					            ->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
 | 
					    protected function generateAvatarsForUsers(Collection $users): void
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -38,36 +38,70 @@
 | 
				
			|||||||
          <div class="h-full">
 | 
					          <div class="h-full">
 | 
				
			||||||
            <div class="grid grid-cols-2 gap-4 h-full">
 | 
					            <div class="grid grid-cols-2 gap-4 h-full">
 | 
				
			||||||
              <div class="px-4 py-5 bg-white shadow-md sm:p-6">
 | 
					              <div class="px-4 py-5 bg-white shadow-md sm:p-6">
 | 
				
			||||||
                <dt class="text-sm font-medium text-gray-500 truncate">
 | 
					                <dd class="mt-1 text-4xl font-semibold text-blumilk-500">
 | 
				
			||||||
                  Limit urlopów
 | 
					 | 
				
			||||||
                </dt>
 | 
					 | 
				
			||||||
                <dd class="mt-1 text-3xl font-semibold text-gray-900">
 | 
					 | 
				
			||||||
                  {{ stats.limit }}
 | 
					 | 
				
			||||||
                </dd>
 | 
					 | 
				
			||||||
              </div>
 | 
					 | 
				
			||||||
              <div class="px-4 py-5 bg-white shadow-md sm:p-6">
 | 
					 | 
				
			||||||
                <dt class="text-sm font-medium text-gray-500 truncate">
 | 
					 | 
				
			||||||
                  Dni do wykorzystania
 | 
					 | 
				
			||||||
                </dt>
 | 
					 | 
				
			||||||
                <dd class="mt-1 text-3xl font-semibold text-gray-900">
 | 
					 | 
				
			||||||
                  {{ stats.remaining }}
 | 
					                  {{ stats.remaining }}
 | 
				
			||||||
                </dd>
 | 
					                </dd>
 | 
				
			||||||
 | 
					                <dt class="text-md font-medium text-gray-700 truncate">
 | 
				
			||||||
 | 
					                  Pozostało
 | 
				
			||||||
 | 
					                </dt>
 | 
				
			||||||
 | 
					                <dt class="text-sm font-medium text-gray-500 mt-2">
 | 
				
			||||||
 | 
					                  Dni do wykorzystania teraz.
 | 
				
			||||||
 | 
					                </dt>
 | 
				
			||||||
              </div>
 | 
					              </div>
 | 
				
			||||||
              <div class="px-4 py-5 bg-white shadow-md sm:p-6">
 | 
					              <div class="px-4 py-5 bg-white shadow-md sm:p-6">
 | 
				
			||||||
                <dt class="text-sm font-medium text-gray-500 truncate">
 | 
					                <dd class="mt-1 text-4xl font-semibold text-blumilk-700">
 | 
				
			||||||
                  Dni wykorzystane
 | 
					 | 
				
			||||||
                </dt>
 | 
					 | 
				
			||||||
                <dd class="mt-1 text-3xl font-semibold text-gray-900">
 | 
					 | 
				
			||||||
                  {{ stats.used }}
 | 
					                  {{ stats.used }}
 | 
				
			||||||
                </dd>
 | 
					                </dd>
 | 
				
			||||||
 | 
					                <dt class="text-md font-medium text-gray-700 truncate">
 | 
				
			||||||
 | 
					                  Dni wykorzystane
 | 
				
			||||||
 | 
					                </dt>
 | 
				
			||||||
 | 
					                <dt class="text-sm font-medium text-gray-500 mt-2">
 | 
				
			||||||
 | 
					                  Dni, które zostały już wykorzystane na urlop wypoczynkowy.
 | 
				
			||||||
 | 
					                </dt>
 | 
				
			||||||
              </div>
 | 
					              </div>
 | 
				
			||||||
              <div class="px-4 py-5 bg-white shadow-md sm:p-6">
 | 
					              <div class="px-4 py-5 bg-white shadow-md sm:p-6">
 | 
				
			||||||
                <dt class="text-sm font-medium text-gray-500 truncate">
 | 
					                <dt class="mt-1 text-4xl font-semibold text-blumilk-200">
 | 
				
			||||||
                  Inne urlopy
 | 
					                  {{ stats.pending }}
 | 
				
			||||||
                </dt>
 | 
					                </dt>
 | 
				
			||||||
                <dd class="mt-1 text-3xl font-semibold text-gray-900">
 | 
					                <dd class="text-md font-medium text-gray-500 truncate">
 | 
				
			||||||
                  {{ stats.other }}
 | 
					                  Rozpatrywane
 | 
				
			||||||
                </dd>
 | 
					                </dd>
 | 
				
			||||||
 | 
					                <dt class="text-sm font-medium text-gray-500 mt-2">
 | 
				
			||||||
 | 
					                  Dni czekające na akceptację przełożonych
 | 
				
			||||||
 | 
					                </dt>
 | 
				
			||||||
 | 
					              </div>
 | 
				
			||||||
 | 
					              <div class="px-4 py-5 bg-white shadow-md sm:p-6">
 | 
				
			||||||
 | 
					                <dt class="mt-1 text-4xl font-semibold text-gray-900">
 | 
				
			||||||
 | 
					                  {{ stats.limit }}
 | 
				
			||||||
 | 
					                </dt>
 | 
				
			||||||
 | 
					                <dd class="text-md font-medium text-gray-500 truncate">
 | 
				
			||||||
 | 
					                  Limit urlopu
 | 
				
			||||||
 | 
					                </dd>
 | 
				
			||||||
 | 
					                <dt class="text-sm font-medium text-gray-500 mt-2">
 | 
				
			||||||
 | 
					                  Twój roczny limit urlopu wypoczynkowego.
 | 
				
			||||||
 | 
					                </dt>
 | 
				
			||||||
 | 
					              </div>
 | 
				
			||||||
 | 
					              <div class="px-4 py-5 bg-white shadow-md sm:p-6">
 | 
				
			||||||
 | 
					                <dt class="mt-1 text-4xl font-semibold text-gray-900">
 | 
				
			||||||
 | 
					                  {{ stats.onRequest }}
 | 
				
			||||||
 | 
					                </dt>
 | 
				
			||||||
 | 
					                <dd class="text-md font-medium text-gray-500 truncate">
 | 
				
			||||||
 | 
					                  Urlop na żądanie
 | 
				
			||||||
 | 
					                </dd>
 | 
				
			||||||
 | 
					                <dt class="text-sm font-medium text-gray-500 mt-2">
 | 
				
			||||||
 | 
					                  Ilość dni urlopu na żądanie, który wlicza się w limit urlopu wypoczynkowego.
 | 
				
			||||||
 | 
					                </dt>
 | 
				
			||||||
 | 
					              </div>
 | 
				
			||||||
 | 
					              <div class="px-4 py-5 bg-white shadow-md sm:p-6">
 | 
				
			||||||
 | 
					                <dt class="mt-1 text-4xl font-semibold text-gray-900">
 | 
				
			||||||
 | 
					                  {{ stats.other }}
 | 
				
			||||||
 | 
					                </dt>
 | 
				
			||||||
 | 
					                <dd class="text-md font-medium text-gray-500 truncate">
 | 
				
			||||||
 | 
					                  Inne urlopy
 | 
				
			||||||
 | 
					                </dd>
 | 
				
			||||||
 | 
					                <dt class="text-sm font-medium text-gray-500 mt-2">
 | 
				
			||||||
 | 
					                  Urlopy bezpłatne, okolicznościowe, zwolnienia lekarskie, itd., które zostały już zatwierdzone.
 | 
				
			||||||
 | 
					                </dt>
 | 
				
			||||||
              </div>
 | 
					              </div>
 | 
				
			||||||
            </div>
 | 
					            </div>
 | 
				
			||||||
          </div>
 | 
					          </div>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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']"
 | 
					            :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']"
 | 
				
			||||||
          >
 | 
					          >
 | 
				
			||||||
            <HomeIcon class="mr-4 flex-shrink-0 h-6 w-6 text-blumilk-200" />
 | 
					            <HomeIcon class="mr-4 flex-shrink-0 h-6 w-6 text-blumilk-200" />
 | 
				
			||||||
            Dashboard
 | 
					            Strona główna
 | 
				
			||||||
          </InertiaLink>
 | 
					          </InertiaLink>
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
        <div class="mt-4 pt-4">
 | 
					        <div class="mt-4 pt-4">
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user