#120 - wip
This commit is contained in:
parent
889af3aaa2
commit
a149f05b9b
@ -34,10 +34,10 @@ class UserVacationStatsRetriever
|
||||
public function getUsedVacationDaysByMonth(User $user, YearPeriod $yearPeriod): Collection
|
||||
{
|
||||
return $user->vacations()
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->whereRelation(
|
||||
"vacationRequest",
|
||||
fn(Builder $query): Builder => $query
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->whereIn("type", $this->getLimitableVacationTypes())
|
||||
->states(VacationRequestStatesRetriever::successStates()),
|
||||
)
|
||||
@ -69,11 +69,21 @@ class UserVacationStatsRetriever
|
||||
"vacationRequest",
|
||||
fn(Builder $query): Builder => $query
|
||||
->whereIn("type", $this->getNotLimitableVacationTypes())
|
||||
->whereNot("type", VacationType::HomeOffice)
|
||||
->states(VacationRequestStatesRetriever::successStates()),
|
||||
)
|
||||
->count();
|
||||
}
|
||||
|
||||
public function getHomeOfficeDays(User $user, YearPeriod $yearPeriod): int
|
||||
{
|
||||
return $user
|
||||
->vacations()
|
||||
->whereBelongsTo($yearPeriod)
|
||||
->whereRelation("vacationRequest", "type", VacationType::HomeOffice)
|
||||
->count();
|
||||
}
|
||||
|
||||
public function getRemainingVacationDays(User $user, YearPeriod $yearPeriod): int
|
||||
{
|
||||
$limit = $this->getVacationDaysLimit($user, $yearPeriod);
|
||||
@ -106,4 +116,5 @@ class UserVacationStatsRetriever
|
||||
|
||||
return $types->filter(fn(VacationType $type) => !$this->configRetriever->hasLimit($type));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ class DashboardController extends Controller
|
||||
$limit = $vacationStatsRetriever->getVacationDaysLimit($user, $yearPeriod);
|
||||
$used = $vacationStatsRetriever->getUsedVacationDays($user, $yearPeriod);
|
||||
$pending = $vacationStatsRetriever->getPendingVacationDays($user, $yearPeriod);
|
||||
$homeOffice = $vacationStatsRetriever->getHomeOfficeDays($user, $yearPeriod);
|
||||
$other = $vacationStatsRetriever->getOtherApprovedVacationDays($user, $yearPeriod);
|
||||
$remaining = $limit - $used - $pending;
|
||||
|
||||
@ -69,6 +70,7 @@ class DashboardController extends Controller
|
||||
"remaining" => $remaining,
|
||||
"used" => $used,
|
||||
"pending" => $pending,
|
||||
"homeOffice" => $homeOffice,
|
||||
"other" => $other,
|
||||
],
|
||||
"can" => [
|
||||
|
@ -25,6 +25,7 @@ return [
|
||||
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
|
||||
EmploymentForm::EmploymentContract,
|
||||
],
|
||||
VacationTypeConfigRetriever::KEY_IS_VACATION => true,
|
||||
],
|
||||
VacationType::TimeInLieu->value => [
|
||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => false,
|
||||
@ -34,6 +35,7 @@ return [
|
||||
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
|
||||
EmploymentForm::EmploymentContract,
|
||||
],
|
||||
VacationTypeConfigRetriever::KEY_IS_VACATION => true,
|
||||
],
|
||||
VacationType::Sick->value => [
|
||||
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => false,
|
||||
@ -83,6 +85,7 @@ return [
|
||||
VacationTypeConfigRetriever::KEY_AVAILABLE_FOR => [
|
||||
EmploymentForm::EmploymentContract,
|
||||
],
|
||||
VacationTypeConfigRetriever::KEY_IS_VACATION => true,
|
||||
],
|
||||
VacationTypeConfigRetriever::KEY_IS_VACATION => true,
|
||||
VacationType::Volunteering->value => [
|
||||
|
@ -49,7 +49,7 @@
|
||||
Twój roczny limit urlopu wypoczynkowego.
|
||||
</dt>
|
||||
</div>
|
||||
<div class="col-span-2 py-5 px-4 bg-white shadow-md sm:p-6">
|
||||
<div class="py-5 px-4 bg-white shadow-md sm:p-6">
|
||||
<dt class="mt-1 text-4xl font-semibold text-gray-900">
|
||||
{{ stats.other }}
|
||||
</dt>
|
||||
@ -60,6 +60,17 @@
|
||||
Urlopy bezpłatne, okolicznościowe, zwolnienia lekarskie, itd., które zostały już zatwierdzone.
|
||||
</dt>
|
||||
</div>
|
||||
<div class="py-5 px-4 bg-white shadow-md sm:p-6">
|
||||
<dt class="mt-1 text-4xl font-semibold text-gray-900">
|
||||
{{ stats.homeOffice }}
|
||||
</dt>
|
||||
<dd class="font-medium text-gray-700 truncate text-md">
|
||||
Biuro w domu
|
||||
</dd>
|
||||
<dt class="mt-2 text-sm font-medium text-gray-500">
|
||||
Biuro w domku
|
||||
</dt>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
Loading…
x
Reference in New Issue
Block a user