Kanban / timesheet update

This commit is contained in:
2026-11-30 06:56:14 +02:00
parent 6332ff0fa9
commit a4dbe8ce09
46 changed files with 8091 additions and 331 deletions
@@ -3,6 +3,7 @@
namespace App\Modules\Jobs\Infrastructure\Persistence\Repositories;
use App\Modules\Catalog\Application\Contracts\CatalogQueries;
use App\Modules\Customers\Application\Contracts\CustomerQueries;
use App\Modules\Jobs\Application\Contracts\TaskQueries;
use App\Modules\Jobs\Application\DTOs\BookableTask;
use App\Modules\Jobs\Application\DTOs\NamedId;
@@ -21,8 +22,31 @@ class EloquentTaskQueries implements TaskQueries
public function __construct(
private CatalogQueries $catalog,
private UserAccountQueries $users,
private CustomerQueries $customers,
) {}
public function scheduledTaskIdsFor(int $userId, string $from, string $to): array
{
$booked = DB::table('task_bookings')
->where('user_id', $userId)
->whereBetween('day', [$from, $to])
->pluck('task_id');
$planned = DB::table('tasks')
->where('status', '!=', TaskStatus::Done->value)
->where(fn ($query) => $query
->whereNull('planned_from')
->orWhere(fn ($query) => $query
->where('planned_from', '<=', $to)
->where(fn ($query) => $query->whereNull('planned_to')->orWhere('planned_to', '>=', $from))))
->where(fn ($query) => $query
->where('assignee_user_id', $userId)
->orWhereIn('id', DB::table('task_members')->select('task_id')->where('user_id', $userId)))
->pluck('id');
return $booked->merge($planned)->map(fn ($id): int => (int) $id)->unique()->values()->all();
}
public function tasksOf(int $jobId): array
{
$models = TaskModel::query()
@@ -116,7 +140,11 @@ class EloquentTaskQueries implements TaskQueries
->join('customer_jobs', 'customer_jobs.id', '=', 'tasks.customer_job_id')
->orderBy('customer_jobs.number')
->orderBy('tasks.id')
->get(['tasks.id', 'tasks.customer_job_id', 'tasks.title', 'tasks.work_type_id', 'tasks.status', 'customer_jobs.number', 'customer_jobs.name', 'customer_jobs.status as job_status']);
->get(['tasks.id', 'tasks.customer_job_id', 'tasks.title', 'tasks.work_type_id', 'tasks.status', 'customer_jobs.number', 'customer_jobs.name', 'customer_jobs.status as job_status', 'customer_jobs.customer_id', 'customer_jobs.payment_basis']);
$customerIds = $rows->pluck('customer_id')->map(fn ($id): int => (int) $id)->unique()->values()->all();
$customerNames = $this->customers->namesByIds($customerIds);
$customerColors = $this->customers->headerColorsByIds($customerIds);
$workTypeNames = [];
foreach ($rows->pluck('work_type_id')->unique() as $workTypeId) {
@@ -133,6 +161,10 @@ class EloquentTaskQueries implements TaskQueries
$workTypeNames[(int) $row->work_type_id] ?? '',
JobStatus::from((string) $row->job_status),
TaskStatus::from((string) $row->status),
(int) $row->customer_id,
$customerNames[(int) $row->customer_id] ?? '',
$customerColors[(int) $row->customer_id] ?? null,
$row->payment_basis === null ? null : (string) $row->payment_basis,
))->values()->all();
}