diff --git a/app/Architecture/Providers/AppServiceProvider.php b/app/Architecture/Providers/AppServiceProvider.php index 23059cb..ce611b9 100644 --- a/app/Architecture/Providers/AppServiceProvider.php +++ b/app/Architecture/Providers/AppServiceProvider.php @@ -11,7 +11,6 @@ class AppServiceProvider extends ServiceProvider { public function boot(): void { - Carbon::macro("toDisplayString", fn() => $this->translatedFormat("j F Y")); - Carbon::macro("toDisplayDate", fn() => $this->translatedFormat("d.m.Y")); + Carbon::macro("toDisplayString", fn() => $this->translatedFormat("d.m.Y")); } } diff --git a/app/Domain/Notifications/VacationRequestApprovedNotification.php b/app/Domain/Notifications/VacationRequestApprovedNotification.php index 1243623..b21b98c 100644 --- a/app/Domain/Notifications/VacationRequestApprovedNotification.php +++ b/app/Domain/Notifications/VacationRequestApprovedNotification.php @@ -45,8 +45,8 @@ class VacationRequestApprovedNotification extends Notification $user = $this->user->first_name; $title = $this->vacationRequest->name; $type = $this->vacationRequest->type->label(); - $from = $this->vacationRequest->from->toDisplayDate(); - $to = $this->vacationRequest->to->toDisplayDate(); + $from = $this->vacationRequest->from->toDisplayString(); + $to = $this->vacationRequest->to->toDisplayString(); $days = $this->vacationRequest->vacations()->count(); $requester = $this->vacationRequest->user->fullName; diff --git a/app/Domain/Notifications/VacationRequestCancelledNotification.php b/app/Domain/Notifications/VacationRequestCancelledNotification.php index 48f2c36..bb5d8f4 100644 --- a/app/Domain/Notifications/VacationRequestCancelledNotification.php +++ b/app/Domain/Notifications/VacationRequestCancelledNotification.php @@ -45,8 +45,8 @@ class VacationRequestCancelledNotification extends Notification $user = $this->user->first_name; $title = $this->vacationRequest->name; $type = $this->vacationRequest->type->label(); - $from = $this->vacationRequest->from->toDisplayDate(); - $to = $this->vacationRequest->to->toDisplayDate(); + $from = $this->vacationRequest->from->toDisplayString(); + $to = $this->vacationRequest->to->toDisplayString(); $days = $this->vacationRequest->vacations()->count(); $requester = $this->vacationRequest->user->fullName; diff --git a/app/Domain/Notifications/VacationRequestCreatedNotification.php b/app/Domain/Notifications/VacationRequestCreatedNotification.php index 1a7777d..512191a 100644 --- a/app/Domain/Notifications/VacationRequestCreatedNotification.php +++ b/app/Domain/Notifications/VacationRequestCreatedNotification.php @@ -42,8 +42,8 @@ class VacationRequestCreatedNotification extends Notification $user = $this->vacationRequest->user->first_name; $title = $this->vacationRequest->name; $type = $this->vacationRequest->type->label(); - $from = $this->vacationRequest->from->toDisplayDate(); - $to = $this->vacationRequest->to->toDisplayDate(); + $from = $this->vacationRequest->from->toDisplayString(); + $to = $this->vacationRequest->to->toDisplayString(); $days = $this->vacationRequest->vacations()->count(); $appName = config("app.name"); diff --git a/app/Domain/Notifications/VacationRequestCreatedOnEmployeeBehalf.php b/app/Domain/Notifications/VacationRequestCreatedOnEmployeeBehalf.php index a5d5e14..4d2872a 100644 --- a/app/Domain/Notifications/VacationRequestCreatedOnEmployeeBehalf.php +++ b/app/Domain/Notifications/VacationRequestCreatedOnEmployeeBehalf.php @@ -43,8 +43,8 @@ class VacationRequestCreatedOnEmployeeBehalf extends Notification $user = $this->vacationRequest->user->first_name; $title = $this->vacationRequest->name; $type = $this->vacationRequest->type->label(); - $from = $this->vacationRequest->from->toDisplayDate(); - $to = $this->vacationRequest->to->toDisplayDate(); + $from = $this->vacationRequest->from->toDisplayString(); + $to = $this->vacationRequest->to->toDisplayString(); $days = $this->vacationRequest->vacations()->count(); $appName = config("app.name"); diff --git a/app/Domain/Notifications/VacationRequestRejectedNotification.php b/app/Domain/Notifications/VacationRequestRejectedNotification.php index 78cde0b..e538cf9 100644 --- a/app/Domain/Notifications/VacationRequestRejectedNotification.php +++ b/app/Domain/Notifications/VacationRequestRejectedNotification.php @@ -45,8 +45,8 @@ class VacationRequestRejectedNotification extends Notification $user = $this->user->first_name; $title = $this->vacationRequest->name; $type = $this->vacationRequest->type->label(); - $from = $this->vacationRequest->from->toDisplayDate(); - $to = $this->vacationRequest->to->toDisplayDate(); + $from = $this->vacationRequest->from->toDisplayString(); + $to = $this->vacationRequest->to->toDisplayString(); $days = $this->vacationRequest->vacations()->count(); $requester = $this->vacationRequest->user->fullName; diff --git a/app/Domain/Notifications/VacationRequestWaitsForAdminApprovalNotification.php b/app/Domain/Notifications/VacationRequestWaitsForAdminApprovalNotification.php index f870d4b..4487cde 100644 --- a/app/Domain/Notifications/VacationRequestWaitsForAdminApprovalNotification.php +++ b/app/Domain/Notifications/VacationRequestWaitsForAdminApprovalNotification.php @@ -46,8 +46,8 @@ class VacationRequestWaitsForAdminApprovalNotification extends Notification $requester = $this->vacationRequest->user->fullName; $title = $this->vacationRequest->name; $type = $this->vacationRequest->type->label(); - $from = $this->vacationRequest->from->toDisplayDate(); - $to = $this->vacationRequest->to->toDisplayDate(); + $from = $this->vacationRequest->from->toDisplayString(); + $to = $this->vacationRequest->to->toDisplayString(); $days = $this->vacationRequest->vacations()->count(); return (new MailMessage()) diff --git a/app/Domain/Notifications/VacationRequestWaitsForTechApprovalNotification.php b/app/Domain/Notifications/VacationRequestWaitsForTechApprovalNotification.php index 23e9866..f98cb85 100644 --- a/app/Domain/Notifications/VacationRequestWaitsForTechApprovalNotification.php +++ b/app/Domain/Notifications/VacationRequestWaitsForTechApprovalNotification.php @@ -46,8 +46,8 @@ class VacationRequestWaitsForTechApprovalNotification extends Notification $requester = $this->vacationRequest->user->fullName; $title = $this->vacationRequest->name; $type = $this->vacationRequest->type->label(); - $from = $this->vacationRequest->from->toDisplayDate(); - $to = $this->vacationRequest->to->toDisplayDate(); + $from = $this->vacationRequest->from->toDisplayString(); + $to = $this->vacationRequest->to->toDisplayString(); $days = $this->vacationRequest->vacations()->count(); return (new MailMessage()) diff --git a/app/Domain/Policies/VacationRequestPolicy.php b/app/Domain/Policies/VacationRequestPolicy.php index 3807180..61000ee 100644 --- a/app/Domain/Policies/VacationRequestPolicy.php +++ b/app/Domain/Policies/VacationRequestPolicy.php @@ -10,6 +10,11 @@ use Toby\Eloquent\Models\VacationRequest; class VacationRequestPolicy { + public function listAll(User $user): bool + { + return in_array($user->role, [Role::AdministrativeApprover, Role::TechnicalApprover], true); + } + public function createOnBehalfOfEmployee(User $user): bool { return $user->role === Role::AdministrativeApprover; diff --git a/app/Domain/TimesheetPerUserSheet.php b/app/Domain/TimesheetPerUserSheet.php index 22e5ddc..8e0fa6d 100644 --- a/app/Domain/TimesheetPerUserSheet.php +++ b/app/Domain/TimesheetPerUserSheet.php @@ -24,8 +24,8 @@ use PhpOffice\PhpSpreadsheet\Style\Border; use PhpOffice\PhpSpreadsheet\Style\Fill; use PhpOffice\PhpSpreadsheet\Style\NumberFormat; use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet; -use Toby\Domain\Enums\VacationRequestState; use Toby\Domain\Enums\VacationType; +use Toby\Domain\States\VacationRequest\Approved; use Toby\Eloquent\Models\Holiday; use Toby\Eloquent\Models\User; use Toby\Eloquent\Models\Vacation; @@ -189,7 +189,7 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With return $user->vacations() ->with("vacationRequest") ->whereBetween("date", [$period->start, $period->end]) - ->whereRelation("vacationRequest", "state", VacationRequestState::Approved->value) + ->whereRelation("vacationRequest", "state", Approved::$name) ->get() ->groupBy( [ diff --git a/app/Domain/VacationRequestStatesRetriever.php b/app/Domain/VacationRequestStatesRetriever.php index ebe66fa..0f26cf6 100644 --- a/app/Domain/VacationRequestStatesRetriever.php +++ b/app/Domain/VacationRequestStatesRetriever.php @@ -4,6 +4,7 @@ declare(strict_types=1); namespace Toby\Domain; +use Toby\Domain\Enums\Role; use Toby\Domain\States\VacationRequest\AcceptedByAdministrative; use Toby\Domain\States\VacationRequest\AcceptedByTechnical; use Toby\Domain\States\VacationRequest\Approved; @@ -12,6 +13,7 @@ use Toby\Domain\States\VacationRequest\Created; use Toby\Domain\States\VacationRequest\Rejected; use Toby\Domain\States\VacationRequest\WaitingForAdministrative; use Toby\Domain\States\VacationRequest\WaitingForTechnical; +use Toby\Eloquent\Models\User; class VacationRequestStatesRetriever { @@ -39,6 +41,16 @@ class VacationRequestStatesRetriever ]; } + public static function waitingForUserActionStates(User $user): array + { + return match ($user->role) { + Role::AdministrativeApprover => [WaitingForAdministrative::class], + Role::TechnicalApprover => [WaitingForTechnical::class], + Role::Administrator => [WaitingForAdministrative::class, WaitingForTechnical::class], + default => [], + }; + } + public static function all(): array { return [ @@ -48,12 +60,13 @@ class VacationRequestStatesRetriever ]; } - public static function filterByStatus(string $filter): array + public static function filterByStatusGroup(string $filter, ?User $user = null): array { return match ($filter) { "pending" => self::pendingStates(), "success" => self::successStates(), "failed" => self::failedStates(), + "waiting_for_action" => self::waitingForUserActionStates($user), default => self::all(), }; } diff --git a/app/Infrastructure/Http/Controllers/DashboardController.php b/app/Infrastructure/Http/Controllers/DashboardController.php index f7b6fef..05b13ea 100644 --- a/app/Infrastructure/Http/Controllers/DashboardController.php +++ b/app/Infrastructure/Http/Controllers/DashboardController.php @@ -35,10 +35,18 @@ class DashboardController extends Controller ) ->get(); - $vacationRequests = VacationRequest::query() - ->latest("updated_at") - ->limit(3) - ->get(); + if ($user->can("listAll", VacationRequest::class)) { + $vacationRequests = VacationRequest::query() + ->states(VacationRequestStatesRetriever::waitingForUserActionStates($user)) + ->latest("updated_at") + ->limit(3) + ->get(); + } else { + $vacationRequests = $user->vacationRequests() + ->latest("updated_at") + ->limit(3) + ->get(); + } $holidays = Holiday::query() ->whereDate("date", ">=", $now) @@ -63,6 +71,9 @@ class DashboardController extends Controller "pending" => $pending, "other" => $other, ], + "can" => [ + "listAllVacationRequests" => $user->can("listAll", VacationRequest::class), + ], ]); } } diff --git a/app/Infrastructure/Http/Controllers/VacationRequestController.php b/app/Infrastructure/Http/Controllers/VacationRequestController.php index 71001e3..84ce8e5 100644 --- a/app/Infrastructure/Http/Controllers/VacationRequestController.php +++ b/app/Infrastructure/Http/Controllers/VacationRequestController.php @@ -40,7 +40,7 @@ class VacationRequestController extends Controller ->with("vacations") ->where("year_period_id", $yearPeriodRetriever->selected()->id) ->latest() - ->states(VacationRequestStatesRetriever::filterByStatus($status)) + ->states(VacationRequestStatesRetriever::filterByStatusGroup($status, $request->user())) ->paginate(); return inertia("VacationRequest/Index", [ @@ -51,6 +51,45 @@ class VacationRequestController extends Controller ]); } + public function indexForApprovers( + Request $request, + YearPeriodRetriever $yearPeriodRetriever, + ): RedirectResponse|Response { + if ($request->user()->cannot("listAll", VacationRequest::class)) { + return redirect()->route("vacation.requests.index"); + } + + $yearPeriod = $yearPeriodRetriever->selected(); + $status = $request->get("status"); + $user = $request->get("user"); + + $vacationRequests = VacationRequest::query() + ->with(["user", "vacations"]) + ->where("year_period_id", $yearPeriod->id) + ->when($user !== null, fn(Builder $query) => $query->where("user_id", $user)) + ->when($status !== null, fn(Builder $query) => $query->states(VacationRequestStatesRetriever::filterByStatusGroup($status, $request->user()))) + ->latest() + ->paginate(); + + $users = User::query() + ->whereRelation( + "vacationlimits", + fn(Builder $query) => $query->where("year_period_id", $yearPeriod->id)->whereNotNull("days"), + ) + ->orderBy("last_name") + ->orderBy("first_name") + ->get(); + + return inertia("VacationRequest/IndexForApprovers", [ + "requests" => VacationRequestResource::collection($vacationRequests), + "users" => UserResource::collection($users), + "filters" => [ + "status" => $status, + "user" => $user, + ], + ]); + } + /** * @throws AuthorizationException */ diff --git a/app/Infrastructure/Http/Middleware/HandleInertiaRequests.php b/app/Infrastructure/Http/Middleware/HandleInertiaRequests.php index fb40418..8f45e25 100644 --- a/app/Infrastructure/Http/Middleware/HandleInertiaRequests.php +++ b/app/Infrastructure/Http/Middleware/HandleInertiaRequests.php @@ -7,6 +7,7 @@ namespace Toby\Infrastructure\Http\Middleware; use Illuminate\Http\Request; use Inertia\Middleware; use Toby\Eloquent\Helpers\YearPeriodRetriever; +use Toby\Eloquent\Models\VacationRequest; use Toby\Infrastructure\Http\Resources\UserResource; class HandleInertiaRequests extends Middleware @@ -25,6 +26,7 @@ class HandleInertiaRequests extends Middleware "can" => [ "manageVacationLimits" => $user ? $user->can("manageVacationLimits") : false, "manageUsers" => $user ? $user->can("manageUsers") : false, + "listAllVacationRequests" => $user ? $user->can("listAll", VacationRequest::class) : false, ], ], "flash" => fn() => [ diff --git a/app/Infrastructure/Http/Resources/VacationRequestActivityResource.php b/app/Infrastructure/Http/Resources/VacationRequestActivityResource.php index 976050e..794f218 100644 --- a/app/Infrastructure/Http/Resources/VacationRequestActivityResource.php +++ b/app/Infrastructure/Http/Resources/VacationRequestActivityResource.php @@ -13,7 +13,7 @@ class VacationRequestActivityResource extends JsonResource public function toArray($request): array { return [ - "date" => $this->created_at->toDisplayDate(), + "date" => $this->created_at->toDisplayString(), "time" => $this->created_at->format("H:i"), "user" => $this->user ? $this->user->fullName : __("System"), "state" => $this->to, diff --git a/composer.lock b/composer.lock index 3fbeb24..6f6abe7 100644 --- a/composer.lock +++ b/composer.lock @@ -1093,16 +1093,16 @@ }, { "name": "google/apiclient-services", - "version": "v0.237.0", + "version": "v0.238.0", "source": { "type": "git", "url": "https://github.com/googleapis/google-api-php-client-services.git", - "reference": "c10652adc29b4242237075acde318e83f88ab918" + "reference": "627e6cda424d690640504e03f3e2e1259d952363" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/c10652adc29b4242237075acde318e83f88ab918", - "reference": "c10652adc29b4242237075acde318e83f88ab918", + "url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/627e6cda424d690640504e03f3e2e1259d952363", + "reference": "627e6cda424d690640504e03f3e2e1259d952363", "shasum": "" }, "require": { @@ -1131,9 +1131,9 @@ ], "support": { "issues": "https://github.com/googleapis/google-api-php-client-services/issues", - "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.237.0" + "source": "https://github.com/googleapis/google-api-php-client-services/tree/v0.238.0" }, - "time": "2022-02-23T22:58:02+00:00" + "time": "2022-03-06T01:18:12+00:00" }, { "name": "google/auth", @@ -2587,16 +2587,16 @@ }, { "name": "league/flysystem", - "version": "3.0.10", + "version": "3.0.11", "source": { "type": "git", "url": "https://github.com/thephpleague/flysystem.git", - "reference": "bbc5026adb5a423dfcdcecec74c7e15943ff6115" + "reference": "1ca148713c23cadeb9d7526973f81fb4a04090a3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/bbc5026adb5a423dfcdcecec74c7e15943ff6115", - "reference": "bbc5026adb5a423dfcdcecec74c7e15943ff6115", + "url": "https://api.github.com/repos/thephpleague/flysystem/zipball/1ca148713c23cadeb9d7526973f81fb4a04090a3", + "reference": "1ca148713c23cadeb9d7526973f81fb4a04090a3", "shasum": "" }, "require": { @@ -2657,7 +2657,7 @@ ], "support": { "issues": "https://github.com/thephpleague/flysystem/issues", - "source": "https://github.com/thephpleague/flysystem/tree/3.0.10" + "source": "https://github.com/thephpleague/flysystem/tree/3.0.11" }, "funding": [ { @@ -2673,7 +2673,7 @@ "type": "tidelift" } ], - "time": "2022-02-26T11:09:13+00:00" + "time": "2022-03-04T16:40:17+00:00" }, { "name": "league/mime-type-detection", @@ -5697,16 +5697,16 @@ }, { "name": "symfony/http-foundation", - "version": "v6.0.5", + "version": "v6.0.6", "source": { "type": "git", "url": "https://github.com/symfony/http-foundation.git", - "reference": "b460fb15905eef449c4c43a4f0c113eccee103b9" + "reference": "a000fcf2298a1bc79a1dcff22608792506534719" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/b460fb15905eef449c4c43a4f0c113eccee103b9", - "reference": "b460fb15905eef449c4c43a4f0c113eccee103b9", + "url": "https://api.github.com/repos/symfony/http-foundation/zipball/a000fcf2298a1bc79a1dcff22608792506534719", + "reference": "a000fcf2298a1bc79a1dcff22608792506534719", "shasum": "" }, "require": { @@ -5749,7 +5749,7 @@ "description": "Defines an object-oriented layer for the HTTP specification", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-foundation/tree/v6.0.5" + "source": "https://github.com/symfony/http-foundation/tree/v6.0.6" }, "funding": [ { @@ -5765,20 +5765,20 @@ "type": "tidelift" } ], - "time": "2022-02-21T17:15:17+00:00" + "time": "2022-03-05T21:04:00+00:00" }, { "name": "symfony/http-kernel", - "version": "v6.0.5", + "version": "v6.0.6", "source": { "type": "git", "url": "https://github.com/symfony/http-kernel.git", - "reference": "5ad3f5e5fa772a8b5c6bb217f8379b533afac2ba" + "reference": "f9e49ad9fe16895b24cd7a09dc28d3364282e21a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/5ad3f5e5fa772a8b5c6bb217f8379b533afac2ba", - "reference": "5ad3f5e5fa772a8b5c6bb217f8379b533afac2ba", + "url": "https://api.github.com/repos/symfony/http-kernel/zipball/f9e49ad9fe16895b24cd7a09dc28d3364282e21a", + "reference": "f9e49ad9fe16895b24cd7a09dc28d3364282e21a", "shasum": "" }, "require": { @@ -5858,7 +5858,7 @@ "description": "Provides a structured process for converting a Request into a Response", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/http-kernel/tree/v6.0.5" + "source": "https://github.com/symfony/http-kernel/tree/v6.0.6" }, "funding": [ { @@ -5874,7 +5874,7 @@ "type": "tidelift" } ], - "time": "2022-02-28T08:05:03+00:00" + "time": "2022-03-05T21:19:20+00:00" }, { "name": "symfony/mailer", @@ -6033,7 +6033,7 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", @@ -6095,7 +6095,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0" }, "funding": [ { @@ -6115,7 +6115,7 @@ }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", @@ -6176,7 +6176,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.25.0" }, "funding": [ { @@ -6196,7 +6196,7 @@ }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", @@ -6263,7 +6263,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.25.0" }, "funding": [ { @@ -6283,7 +6283,7 @@ }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", @@ -6347,7 +6347,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.25.0" }, "funding": [ { @@ -6367,7 +6367,7 @@ }, { "name": "symfony/polyfill-mbstring", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", @@ -6430,7 +6430,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.25.0" }, "funding": [ { @@ -6450,7 +6450,7 @@ }, { "name": "symfony/polyfill-php72", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", @@ -6506,7 +6506,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-php72/tree/v1.25.0" }, "funding": [ { @@ -6526,16 +6526,16 @@ }, { "name": "symfony/polyfill-php80", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9" + "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/57b712b08eddb97c762a8caa32c84e037892d2e9", - "reference": "57b712b08eddb97c762a8caa32c84e037892d2e9", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4407588e0d3f1f52efb65fbe92babe41f37fe50c", + "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c", "shasum": "" }, "require": { @@ -6589,7 +6589,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.25.0" }, "funding": [ { @@ -6605,11 +6605,11 @@ "type": "tidelift" } ], - "time": "2021-09-13T13:58:33+00:00" + "time": "2022-03-04T08:16:47+00:00" }, { "name": "symfony/polyfill-php81", - "version": "v1.24.0", + "version": "v1.25.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php81.git", @@ -6668,7 +6668,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.24.0" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.25.0" }, "funding": [ { @@ -7004,16 +7004,16 @@ }, { "name": "symfony/translation", - "version": "v6.0.5", + "version": "v6.0.6", "source": { "type": "git", "url": "https://github.com/symfony/translation.git", - "reference": "e69501c71107cc3146b32aaa45f4edd0c3427875" + "reference": "f6639cb9b5e0c57fe31e3263b900a77eedb0c908" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/translation/zipball/e69501c71107cc3146b32aaa45f4edd0c3427875", - "reference": "e69501c71107cc3146b32aaa45f4edd0c3427875", + "url": "https://api.github.com/repos/symfony/translation/zipball/f6639cb9b5e0c57fe31e3263b900a77eedb0c908", + "reference": "f6639cb9b5e0c57fe31e3263b900a77eedb0c908", "shasum": "" }, "require": { @@ -7079,7 +7079,7 @@ "description": "Provides tools to internationalize your application", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/translation/tree/v6.0.5" + "source": "https://github.com/symfony/translation/tree/v6.0.6" }, "funding": [ { @@ -7095,7 +7095,7 @@ "type": "tidelift" } ], - "time": "2022-02-09T15:52:48+00:00" + "time": "2022-03-02T12:58:14+00:00" }, { "name": "symfony/translation-contracts", @@ -7177,16 +7177,16 @@ }, { "name": "symfony/var-dumper", - "version": "v6.0.5", + "version": "v6.0.6", "source": { "type": "git", "url": "https://github.com/symfony/var-dumper.git", - "reference": "60d6a756d5f485df5e6e40b337334848f79f61ce" + "reference": "38358405ae948963c50a3aae3dfea598223ba15e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/var-dumper/zipball/60d6a756d5f485df5e6e40b337334848f79f61ce", - "reference": "60d6a756d5f485df5e6e40b337334848f79f61ce", + "url": "https://api.github.com/repos/symfony/var-dumper/zipball/38358405ae948963c50a3aae3dfea598223ba15e", + "reference": "38358405ae948963c50a3aae3dfea598223ba15e", "shasum": "" }, "require": { @@ -7245,7 +7245,7 @@ "dump" ], "support": { - "source": "https://github.com/symfony/var-dumper/tree/v6.0.5" + "source": "https://github.com/symfony/var-dumper/tree/v6.0.6" }, "funding": [ { @@ -7261,7 +7261,7 @@ "type": "tidelift" } ], - "time": "2022-02-21T17:15:17+00:00" + "time": "2022-03-02T12:58:14+00:00" }, { "name": "tijsverkoyen/css-to-inline-styles", @@ -9011,16 +9011,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.14", + "version": "9.2.15", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "9f4d60b6afe5546421462b76cd4e633ebc364ab4" + "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/9f4d60b6afe5546421462b76cd4e633ebc364ab4", - "reference": "9f4d60b6afe5546421462b76cd4e633ebc364ab4", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2e9da11878c4202f97915c1cb4bb1ca318a63f5f", + "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f", "shasum": "" }, "require": { @@ -9076,7 +9076,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.14" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.15" }, "funding": [ { @@ -9084,7 +9084,7 @@ "type": "github" } ], - "time": "2022-02-28T12:38:02+00:00" + "time": "2022-03-07T09:28:20+00:00" }, { "name": "phpunit/php-file-iterator", @@ -9329,16 +9329,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.16", + "version": "9.5.17", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "5ff8c545a50226c569310a35f4fa89d79f1ddfdc" + "reference": "5c5abcfaa2cbd44b2203995d7a339ef910fe0c8f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5ff8c545a50226c569310a35f4fa89d79f1ddfdc", - "reference": "5ff8c545a50226c569310a35f4fa89d79f1ddfdc", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/5c5abcfaa2cbd44b2203995d7a339ef910fe0c8f", + "reference": "5c5abcfaa2cbd44b2203995d7a339ef910fe0c8f", "shasum": "" }, "require": { @@ -9416,7 +9416,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.16" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.17" }, "funding": [ { @@ -9428,7 +9428,7 @@ "type": "github" } ], - "time": "2022-02-23T17:10:58+00:00" + "time": "2022-03-05T16:54:31+00:00" }, { "name": "sebastian/cli-parser", @@ -10522,16 +10522,16 @@ }, { "name": "spatie/ignition", - "version": "1.1.1", + "version": "1.2.1", "source": { "type": "git", "url": "https://github.com/spatie/ignition.git", - "reference": "5c554067887b7080bc58977fa30a488624d85d20" + "reference": "090518ff676e17a038dfe77490018363ff66af20" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/ignition/zipball/5c554067887b7080bc58977fa30a488624d85d20", - "reference": "5c554067887b7080bc58977fa30a488624d85d20", + "url": "https://api.github.com/repos/spatie/ignition/zipball/090518ff676e17a038dfe77490018363ff66af20", + "reference": "090518ff676e17a038dfe77490018363ff66af20", "shasum": "" }, "require": { @@ -10589,7 +10589,7 @@ "type": "github" } ], - "time": "2022-03-02T10:51:55+00:00" + "time": "2022-03-04T12:52:17+00:00" }, { "name": "spatie/laravel-ignition", @@ -10680,16 +10680,16 @@ }, { "name": "symfony/filesystem", - "version": "v6.0.5", + "version": "v6.0.6", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "6646c13f787057d64701a3a0235cf9567c6ccbbd" + "reference": "52b888523545b0b4049ab9ce48766802484d7046" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/6646c13f787057d64701a3a0235cf9567c6ccbbd", - "reference": "6646c13f787057d64701a3a0235cf9567c6ccbbd", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/52b888523545b0b4049ab9ce48766802484d7046", + "reference": "52b888523545b0b4049ab9ce48766802484d7046", "shasum": "" }, "require": { @@ -10723,7 +10723,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v6.0.5" + "source": "https://github.com/symfony/filesystem/tree/v6.0.6" }, "funding": [ { @@ -10739,7 +10739,7 @@ "type": "tidelift" } ], - "time": "2022-02-28T07:42:30+00:00" + "time": "2022-03-02T12:58:14+00:00" }, { "name": "symfony/options-resolver", diff --git a/docker/dev/php/Dockerfile b/docker/dev/php/Dockerfile index da0c855..d068a6c 100644 --- a/docker/dev/php/Dockerfile +++ b/docker/dev/php/Dockerfile @@ -9,14 +9,16 @@ RUN if [ ${INSTALL_XDEBUG} = true ]; then \ && docker-php-ext-enable xdebug \ ;fi -RUN pecl install redis \ - && apk --no-cache add \ +RUN apk add --no-cache pcre-dev $PHPIZE_DEPS \ postgresql-dev \ zip \ libzip-dev \ + libpng-dev \ + && pecl install redis \ && docker-php-ext-install \ pdo_pgsql \ zip \ + gd \ && docker-php-ext-configure \ zip \ && docker-php-ext-enable \ diff --git a/resources/js/Composables/statusInfo.js b/resources/js/Composables/statusInfo.js index 6a459ca..91e7ceb 100644 --- a/resources/js/Composables/statusInfo.js +++ b/resources/js/Composables/statusInfo.js @@ -123,6 +123,12 @@ const statuses = [ }, ] -export function useStatusInfo(status) { - return statuses.find(statusInfo => statusInfo.value === status) +export function useStatusInfo() { + const getStatues = () => statuses + const findStatus = value => statuses.find(month => month.value === value) + + return { + getStatues, + findStatus, + } } diff --git a/resources/js/Pages/Dashboard.vue b/resources/js/Pages/Dashboard.vue index 51730f8..caced10 100644 --- a/resources/js/Pages/Dashboard.vue +++ b/resources/js/Pages/Dashboard.vue @@ -11,7 +11,6 @@
@@ -98,7 +97,73 @@
-
+
+
+
+

+ Wnioski oczekujące na akcje +

+
+
+
+
    +
  • +
    +

    + + + Wniosek o {{ request.type.toLowerCase() }} + [{{ request.name }}] + +

    +

    + {{ request.from }} - {{ request.to }} +

    +
    +
    + +
    +

    + {{ request.user.name }} +

    +

    + {{ request.user.email }} +

    +
    +
    +
    +
    +
  • +
  • +

    + Brak danych +

    +
  • +
+
+
+ + Zobacz wszystkie + +
+
+
+
+

@@ -113,7 +178,7 @@ :key="request.id" class="py-5" > -
+

+
  • +

    + Brak danych +

    +
  • Zobacz wszystkie @@ -205,11 +275,16 @@

    +
  • +

    + Brak danych +

    +
  • Zobacz wszystkie @@ -244,6 +319,10 @@ export default { type: Object, default: null, }, + can: { + type: Object, + default: null, + }, stats: { type: Object, default: () => ({ diff --git a/resources/js/Pages/VacationRequest/Index.vue b/resources/js/Pages/VacationRequest/Index.vue index 49a30c0..600dec2 100644 --- a/resources/js/Pages/VacationRequest/Index.vue +++ b/resources/js/Pages/VacationRequest/Index.vue @@ -9,7 +9,7 @@
    Dodaj wniosek @@ -74,7 +74,7 @@ + + +
    +
    +
    +

    + Wnioski urlopowe +

    +
    +
    + + Dodaj wniosek + +
    +
    +
    +
    +
    +
    + + + Pracownik + +
    + + + Wszyscy + + + + {{ form.user.name }} + + + + + + + + + +
  • +
    + Wszyscy pracownicy +
    + + + + +
  • +
    + +
  • +
    + + + {{ user.name }} + +
    + + + +
  • +
    +
    +
    +
    +
    +
    +
    + + + Status + +
    + + + {{ form.status.name }} + + + + + + + + + +
  • + {{ status.name }} + + + + +
  • +
    +
    +
    +
    +
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Numer + + Pracownik + + Rodzaj urlopu + + Od + + Do + + Dni urlopu + + Status + +
    + + {{ request.name }} + + +
    + +
    +

    + {{ request.user.name }} +

    +

    + {{ request.user.email }} +

    +
    +
    +
    + {{ request.type }} + + {{ request.from }} + + {{ request.to }} + + {{ request.days.length }} + + + + + + + +
    + Brak danych +
    +
    +
    + + Poprzednia + + + Następna + +
    + +
    +
    +
    + + + diff --git a/resources/js/Pages/VacationRequest/Show.vue b/resources/js/Pages/VacationRequest/Show.vue index aa3cb6f..345e937 100644 --- a/resources/js/Pages/VacationRequest/Show.vue +++ b/resources/js/Pages/VacationRequest/Show.vue @@ -19,11 +19,24 @@
    -
    +
    Pracownik
    - {{ request.user.name }} +
    + +
    +

    + {{ request.user.name }} +

    +

    + {{ request.user.email }} +

    +
    +
    @@ -44,26 +57,17 @@
    - Urlop od + Data
    - {{ request.from }} -
    -
    -
    -
    - Urlop do -
    -
    - {{ request.to }} -
    -
    -
    -
    - Dni urlopu -
    -
    - {{ request.days.length }} + + + +
    @@ -84,7 +88,7 @@
    -
    +
    Załączniki
    diff --git a/resources/js/Shared/Activity.vue b/resources/js/Shared/Activity.vue index 050889c..d183714 100644 --- a/resources/js/Shared/Activity.vue +++ b/resources/js/Shared/Activity.vue @@ -48,7 +48,9 @@ export default { }, }, setup(props) { - const statusInfo = computed(() => useStatusInfo(props.activity.state)) + const { findStatus } = useStatusInfo() + + const statusInfo = computed(() => findStatus(props.activity.state)) return { statusInfo, diff --git a/resources/js/Shared/MainMenu.vue b/resources/js/Shared/MainMenu.vue index 7d47bfc..5bd78cf 100644 --- a/resources/js/Shared/MainMenu.vue +++ b/resources/js/Shared/MainMenu.vue @@ -74,7 +74,7 @@ v-for="item in navigation" :key="item.name" :href="item.href" - :class="[$page.url.startsWith(item.href) ? 'bg-blumilk-800 text-white' : 'text-blumilk-100 hover:text-white hover:bg-blumilk-600', 'group flex items-center px-2 py-2 text-base font-medium rounded-md']" + :class="[$page.url === item.href ? 'bg-blumilk-800 text-white' : 'text-blumilk-100 hover:text-white hover:bg-blumilk-600', 'group flex items-center px-2 py-2 text-base font-medium rounded-md']" > [ - {name: 'Wnioski urlopowe', href: '/vacation-requests', icon: CollectionIcon, can: true}, + {name: 'Moje wnioski', href: '/vacation-requests/me', icon: DocumentTextIcon, can: true}, + {name: 'Wnioski urlopowe', href: '/vacation-requests', icon: CollectionIcon, can: auth.value.can.listAllVacationRequests}, {name: 'Kalendarz urlopów', href: '/vacation-calendar', icon: CalendarIcon, can: true}, {name: 'Dni wolne', href: '/holidays', icon: StarIcon, can: true}, {name: 'Limity urlopów', href: '/vacation-limits', icon: SunIcon, can: auth.value.can.manageVacationLimits}, diff --git a/resources/js/Shared/Status.vue b/resources/js/Shared/Status.vue index 6588c7f..0b8ed58 100644 --- a/resources/js/Shared/Status.vue +++ b/resources/js/Shared/Status.vue @@ -25,7 +25,9 @@ export default { }, }, setup(props) { - const statusInfo = computed(() => useStatusInfo(props.status)) + const { findStatus } = useStatusInfo() + + const statusInfo = computed(() => findStatus(props.status)) return { statusInfo, diff --git a/resources/js/app.js b/resources/js/app.js index 4d9a68e..14ebf63 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -38,7 +38,7 @@ Flatpickr.localize(Polish) Flatpickr.setDefaults({ dateFormat: 'Y-m-d', enableTime: false, - altFormat: 'j F Y', + altFormat: 'd.m.Y', altInput: true, }) diff --git a/routes/web.php b/routes/web.php index 1436160..c3505ad 100644 --- a/routes/web.php +++ b/routes/web.php @@ -34,8 +34,10 @@ Route::middleware("auth")->group(function (): void { Route::get("/vacation-limits", [VacationLimitController::class, "edit"])->name("vacation.limits"); Route::put("/vacation-limits", [VacationLimitController::class, "update"]); - Route::get("/vacation-requests", [VacationRequestController::class, "index"]) + Route::get("/vacation-requests/me", [VacationRequestController::class, "index"]) ->name("vacation.requests.index"); + Route::get("/vacation-requests", [VacationRequestController::class, "indexForApprovers"]) + ->name("vacation.requests.indexForApprovers"); Route::get("/vacation-requests/create", [VacationRequestController::class, "create"]) ->name("vacation.requests.create"); Route::post("/vacation-requests", [VacationRequestController::class, "store"]) diff --git a/tests/Feature/VacationRequestTest.php b/tests/Feature/VacationRequestTest.php index 91da0b2..deee29f 100644 --- a/tests/Feature/VacationRequestTest.php +++ b/tests/Feature/VacationRequestTest.php @@ -49,7 +49,7 @@ class VacationRequestTest extends FeatureTestCase ->create(); $this->actingAs($user) - ->get("/vacation-requests") + ->get("/vacation-requests/me") ->assertOk() ->assertInertia( fn(Assert $page) => $page