wip
This commit is contained in:
		| @@ -0,0 +1,46 @@ | ||||
| <?php | ||||
|  | ||||
| declare(strict_types=1); | ||||
|  | ||||
| namespace Toby\Infrastructure\Http\Controllers; | ||||
|  | ||||
| use Illuminate\Http\Request; | ||||
| use Illuminate\Support\Carbon; | ||||
| use Inertia\Response; | ||||
| use Toby\Eloquent\Helpers\YearPeriodRetriever; | ||||
| use Toby\Eloquent\Models\Holiday; | ||||
| use Toby\Eloquent\Models\Vacation; | ||||
|  | ||||
| class AnnualSummaryController extends Controller | ||||
| { | ||||
|     public function __invoke(Request $request, YearPeriodRetriever $yearPeriodRetriever): Response { | ||||
|         $yearPeriod = $yearPeriodRetriever->selected(); | ||||
|  | ||||
|         $startDate = Carbon::createFromDate($yearPeriod->year)->startOfYear()->startOfWeek(); | ||||
|         $endDate = Carbon::createFromDate($yearPeriod->year)->endOfYear()->endOfWeek(); | ||||
|  | ||||
|         $holidays = $yearPeriod->holidays() | ||||
|             ->whereBetween("date", [$startDate, $endDate]) | ||||
|             ->get(); | ||||
|  | ||||
|         $vacations = $request->user() | ||||
|             ->vacations() | ||||
|             ->with("vacationRequest") | ||||
|             ->whereBetween("date", [$startDate, $endDate]) | ||||
|             ->approved() | ||||
|             ->get(); | ||||
|  | ||||
|         $pendingVacations = $request->user() | ||||
|             ->vacations() | ||||
|             ->with("vacationRequest") | ||||
|             ->whereBetween("date", [$startDate, $endDate]) | ||||
|             ->pending() | ||||
|             ->get(); | ||||
|  | ||||
|         return inertia("AnnualSummary", [ | ||||
|             "holidays" => $holidays->mapWithKeys(fn(Holiday $holiday) => [$holiday->date->toDateString() => $holiday->name]), | ||||
|             "vacations" => $vacations->mapWithKeys(fn(Vacation $vacation) => [$vacation->date->toDateString() => $vacation->vacationRequest->type]), | ||||
|             "pendingVacations" => $pendingVacations->mapWithKeys(fn(Vacation $vacation) => [$vacation->date->toDateString() => $vacation->vacationRequest->type]), | ||||
|         ]); | ||||
|     } | ||||
| } | ||||
| @@ -24,18 +24,35 @@ | ||||
|           <div>Nd</div> | ||||
|         </div> | ||||
|         <div class="grid isolate grid-cols-7 mt-2 text-sm ring-1 ring-gray-200 shadow"> | ||||
|           <Component | ||||
|             :is="day.isCurrentMonth ? 'button' : 'div'" | ||||
|           <template | ||||
|             v-for="(day, dayIdx) in month.days" | ||||
|             :key="dayIdx" | ||||
|             :class="[day.isCurrentMonth ? 'bg-white hover:bg-gray-100' : 'bg-gray-50 text-gray-400', day.isVacation && `${getVacationBorder(day.date)}`, day.isPendingVacation && `border-dashed mx-0.5 ${getPendingVacationBorder(day.date)}`, 'border-b-4 border-transparent py-1.5 focus:z-10 font-medium']" | ||||
|           > | ||||
|             <div :class="[day.isCurrentMonth && (day.isWeekend || day.isHoliday) && 'text-red-600 font-bold', day.isToday && 'bg-blumilk-500 font-semibold text-white rounded-full', 'mx-auto flex h-7 w-7 p-4 items-center justify-center']"> | ||||
|               <time :datetime="day.date.toISODate()"> | ||||
|                 {{ day.date.day }} | ||||
|               </time> | ||||
|             <div | ||||
|               v-if="day.isCurrentMonth" | ||||
|               :class="[day.isVacation && `${getVacationBorder(day.date)}`, day.isPendingVacation && `border-dashed mx-0.5 ${getPendingVacationBorder(day.date)}`, !day.isVacation && !day.isPendingVacation && 'border-transparent', 'relative bg-white hover:bg-gray-100 border-b-4 py-1.5 focus:z-10 font-medium']" | ||||
|             > | ||||
|               <div :class="[day.isCurrentMonth && (day.isWeekend || day.isHoliday) && 'text-red-600 font-bold', day.isToday && 'bg-blumilk-500 font-semibold text-white rounded-full', 'mx-auto flex h-7 w-7 p-4 items-center justify-center']"> | ||||
|                 <time :datetime="day.date.toISODate()"> | ||||
|                   {{ day.date.day }} | ||||
|                 </time> | ||||
|               </div> | ||||
|               <InertiaLink | ||||
|                 :href="`/vacation/requests/${dayIdx}`" | ||||
|                 class="absolute inset-0" | ||||
|               /> | ||||
|             </div> | ||||
|           </Component> | ||||
|             <div | ||||
|               v-else | ||||
|               :class="['bg-gray-50 text-gray-400 border-b-4 border-transparent py-1.5 w-full focus:z-10 font-medium']" | ||||
|             > | ||||
|               <div class="flex justify-center items-center p-4 mx-auto w-7 h-7"> | ||||
|                 <time :datetime="day.date.toISODate()"> | ||||
|                   {{ day.date.day }} | ||||
|                 </time> | ||||
|               </div> | ||||
|             </div> | ||||
|           </template> | ||||
|         </div> | ||||
|       </section> | ||||
|     </div> | ||||
| @@ -335,6 +335,14 @@ const navigation = computed(() => | ||||
|       icon: SunIcon, | ||||
|       can: props.auth.can.manageVacationLimits, | ||||
|     }, | ||||
|     { | ||||
|  | ||||
|       name: 'Podsumowanie roczne', | ||||
|       href: '/vacation/annual-summary', | ||||
|       component: 'AnnualSummary', | ||||
|       icon: SunIcon, | ||||
|       can: true, | ||||
|     }, | ||||
|     { | ||||
|       name: 'Użytkownicy', | ||||
|       href: '/users', | ||||
|   | ||||
| @@ -2,12 +2,8 @@ | ||||
|  | ||||
| declare(strict_types=1); | ||||
|  | ||||
| use Illuminate\Http\Request; | ||||
| use Illuminate\Support\Carbon; | ||||
| use Illuminate\Support\Facades\Route; | ||||
| use Toby\Eloquent\Helpers\YearPeriodRetriever; | ||||
| use Toby\Eloquent\Models\Holiday; | ||||
| use Toby\Eloquent\Models\Vacation; | ||||
| use Toby\Infrastructure\Http\Controllers\AnnualSummaryController; | ||||
| use Toby\Infrastructure\Http\Controllers\DashboardController; | ||||
| use Toby\Infrastructure\Http\Controllers\GoogleController; | ||||
| use Toby\Infrastructure\Http\Controllers\HolidayController; | ||||
| @@ -33,72 +29,44 @@ Route::middleware("auth")->group(function (): void { | ||||
|     Route::post("year-periods/{yearPeriod}/select", SelectYearPeriodController::class) | ||||
|         ->name("year-periods.select"); | ||||
|  | ||||
|     Route::prefix("/vacation")->group(function (): void { | ||||
|     Route::prefix("/vacation")->as("vacation.")->group(function (): void { | ||||
|         Route::get("/limits", [VacationLimitController::class, "edit"]) | ||||
|             ->name("vacation.limits"); | ||||
|             ->name("limits"); | ||||
|         Route::get("/calendar/{month?}", [VacationCalendarController::class, "index"]) | ||||
|             ->name("vacation.calendar"); | ||||
|             ->name("calendar"); | ||||
|         Route::get("/timesheet/{month}", TimesheetController::class) | ||||
|             ->name("timesheet"); | ||||
|  | ||||
|         Route::get("/limits", [VacationLimitController::class, "edit"]) | ||||
|             ->name("vacation.limits"); | ||||
|             ->name("limits"); | ||||
|         Route::put("/limits", [VacationLimitController::class, "update"]); | ||||
|  | ||||
|         Route::get("/requests", [VacationRequestController::class, "indexForApprovers"]) | ||||
|             ->name("vacation.requests.indexForApprovers"); | ||||
|             ->name("requests.indexForApprovers"); | ||||
|         Route::get("/requests/me", [VacationRequestController::class, "index"]) | ||||
|             ->name("vacation.requests.index"); | ||||
|             ->name("requests.index"); | ||||
|         Route::get("/requests/create", [VacationRequestController::class, "create"]) | ||||
|             ->name("vacation.requests.create"); | ||||
|             ->name("requests.create"); | ||||
|         Route::post("/requests", [VacationRequestController::class, "store"]) | ||||
|             ->name("vacation.requests.store"); | ||||
|             ->name("requests.store"); | ||||
|         Route::get("/requests/{vacationRequest}", [VacationRequestController::class, "show"]) | ||||
|             ->name("vacation.requests.show"); | ||||
|             ->name("requests.show"); | ||||
|         Route::get("/requests/{vacationRequest}/download", [VacationRequestController::class, "download"]) | ||||
|             ->name("vacation.requests.download"); | ||||
|             ->name("requests.download"); | ||||
|         Route::post("/requests/{vacationRequest}/reject", [VacationRequestController::class, "reject"]) | ||||
|             ->name("vacation.requests.reject"); | ||||
|             ->name("requests.reject"); | ||||
|         Route::post("/requests/{vacationRequest}/cancel", [VacationRequestController::class, "cancel"]) | ||||
|             ->name("vacation.requests.cancel"); | ||||
|             ->name("requests.cancel"); | ||||
|         Route::post("/requests/{vacationRequest}/accept-as-technical", [VacationRequestController::class, "acceptAsTechnical"], ) | ||||
|             ->name("vacation.requests.accept-as-technical"); | ||||
|             ->name("requests.accept-as-technical"); | ||||
|         Route::post("/requests/{vacationRequest}/accept-as-administrative", [VacationRequestController::class, "acceptAsAdministrative"], ) | ||||
|             ->name("vacation.requests.accept-as-administrative"); | ||||
|             ->name("requests.accept-as-administrative"); | ||||
|  | ||||
|         Route::get("/monthly-usage", MonthlyUsageController::class) | ||||
|             ->name("vacation.monthly-usage"); | ||||
|     }); | ||||
|             ->name("monthly-usage"); | ||||
|         Route::get("/annual-summary", AnnualSummaryController::class) | ||||
|             ->name("annual-summmary"); | ||||
|  | ||||
|     Route::get("/test", function (Request $request, YearPeriodRetriever $yearPeriodRetriever) { | ||||
|         $yearPeriod = $yearPeriodRetriever->selected(); | ||||
|  | ||||
|         $startDate = Carbon::createFromDate($yearPeriod->year)->startOfYear()->startOfWeek(); | ||||
|         $endDate = Carbon::createFromDate($yearPeriod->year)->endOfYear()->endOfWeek(); | ||||
|  | ||||
|         $holidays = $yearPeriod->holidays() | ||||
|             ->whereBetween("date", [$startDate, $endDate]) | ||||
|             ->get(); | ||||
|  | ||||
|         $vacations = $request->user() | ||||
|             ->vacations() | ||||
|             ->with("vacationRequest") | ||||
|             ->whereBetween("date", [$startDate, $endDate]) | ||||
|             ->approved() | ||||
|             ->get(); | ||||
|          | ||||
|         $pendingVacations = $request->user() | ||||
|             ->vacations() | ||||
|             ->with("vacationRequest") | ||||
|             ->whereBetween("date", [$startDate, $endDate]) | ||||
|             ->pending() | ||||
|             ->get(); | ||||
|  | ||||
|         return inertia("Test", [ | ||||
|             "holidays" => $holidays->mapWithKeys(fn(Holiday $holiday) => [$holiday->date->toDateString() => $holiday->name]), | ||||
|             "vacations" => $vacations->mapWithKeys(fn(Vacation $vacation) => [$vacation->date->toDateString() => $vacation->vacationRequest->type]), | ||||
|             "pendingVacations" => $pendingVacations->mapWithKeys(fn(Vacation $vacation) => [$vacation->date->toDateString() => $vacation->vacationRequest->type]), | ||||
|         ]); | ||||
|     }); | ||||
| }); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user