Files
Toiminnanohjaus/app/Modules/TimeTracking/Infrastructure/Providers/TimeTrackingServiceProvider.php
T
petriandClaude Opus 5.5 f4b58f6b1d Darken the dark canvas, add customer colours, the ongoing status and the board model
- Dark theme page background is #5a5e60; text on it is lifted to zinc-200 /
  primary-100 and TallStackUI's dark labels, hints and checkbox labels are
  lightened so everything stays at 4.5:1.
- Shared HexColor picks white or black text by the higher WCAG contrast; a
  native-dialog colour picker and a large work dialog component.
- Customers get a header colour (customers.header_color), set on the
  customer page.
- New job status Jatkuvat / Kausi (ongoing): open, never late, billed
  monthly like running jobs.
- Kanban model: board columns and views, urgent threshold, per-user board
  preferences (density, column colours and sort), card positions, tasks of
  continuing jobs pinned to the board, MoveBoardCard and board queries with
  logged hours from TimeTracking.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-30 06:11:49 +02:00

63 lines
2.7 KiB
PHP

<?php
namespace App\Modules\TimeTracking\Infrastructure\Providers;
use App\Models\User;
use App\Modules\Jobs\Application\Contracts\CustomerJobQueries;
use App\Modules\Jobs\Application\Contracts\LoggedJobHours;
use App\Modules\Jobs\Application\Contracts\TaskUsage;
use App\Modules\TimeTracking\Application\Contracts\TimeEntryQueries;
use App\Modules\TimeTracking\Application\Contracts\TimeReportQueries;
use App\Modules\TimeTracking\Domain\Contracts\TimeEntryRepository;
use App\Modules\TimeTracking\Infrastructure\LoggedHoursFromTimeEntries;
use App\Modules\TimeTracking\Infrastructure\Persistence\Repositories\EloquentTimeEntryQueries;
use App\Modules\TimeTracking\Infrastructure\Persistence\Repositories\EloquentTimeEntryRepository;
use App\Modules\TimeTracking\Infrastructure\Persistence\Repositories\EloquentTimeReportQueries;
use App\Modules\TimeTracking\Infrastructure\TaskUsageFromTimeEntries;
use App\Modules\Users\Domain\Enums\Role;
use Illuminate\Support\Facades\Gate;
use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;
/**
* Wires the TimeTracking module (hours on tasks) into Laravel.
*/
class TimeTrackingServiceProvider extends ServiceProvider
{
/**
* @var array<class-string, class-string>
*/
public array $bindings = [
TimeEntryRepository::class => EloquentTimeEntryRepository::class,
TimeEntryQueries::class => EloquentTimeEntryQueries::class,
TimeReportQueries::class => EloquentTimeReportQueries::class,
TaskUsage::class => TaskUsageFromTimeEntries::class,
LoggedJobHours::class => LoggedHoursFromTimeEntries::class,
];
public function boot(): void
{
$presentationPath = dirname(__DIR__, 2).'/Presentation';
Livewire::addNamespace('time', viewPath: $presentationPath.'/Livewire');
if (! $this->app->routesAreCached()) {
$this->loadRoutesFrom($presentationPath.'/Routes/web.php');
}
Gate::define('time.use', fn (User $user): bool => true);
// Users approve their own hours; management anyone's, including subcontractors' (spec 9).
Gate::define('time.approve', fn (User $user, int $ownerId): bool => $user->role->seesAllMoney()
|| ($user->role !== Role::Subcontractor && $user->id === $ownerId));
Gate::define('time.approve-others', fn (User $user): bool => $user->role->seesAllMoney());
Gate::define('time.cancel-approval', fn (User $user): bool => $user->role->seesAllMoney());
// Hours go on any task of an unlocked job; subcontractors only on jobs they are attached to (K12).
Gate::define('time.book', fn (User $user, int $jobId): bool => $user->role !== Role::Subcontractor
|| app(CustomerJobQueries::class)->isMember($jobId, $user->id));
}
}