Add the task calendar, holidays, workflow templates and customer removal
Task calendar (/jobs/calendar) replaces per-unit task Kanban columns (K34): a two-week Gantt of tasks per person. Bars move, resize and change person by dragging or through a keyboard dialog. Each task's estimate is booked evenly over working days into task_bookings, and what exceeds the daily maximum (jobs.daily_capacity_hours, 8 h) moves to the next working day. Tasks get planned_from/planned_to on the form. Holidays (/settings/holidays): Finnish public holidays calculated per year, which the admin can take out of use, plus company days off. Also includes the earlier uncommitted work: workflow templates with adding tasks from a template, and removing customers no module refers to. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
+50
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
namespace App\Modules\Jobs\Infrastructure\Persistence\Repositories;
|
||||
|
||||
use App\Modules\Jobs\Domain\Contracts\TaskBookingRepository;
|
||||
use App\Modules\Jobs\Domain\Enums\TaskStatus;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class EloquentTaskBookingRepository implements TaskBookingRepository
|
||||
{
|
||||
public function replaceFor(int $taskId, int $userId, array $minutesByDay): void
|
||||
{
|
||||
DB::table('task_bookings')->where('task_id', $taskId)->where('user_id', $userId)->delete();
|
||||
|
||||
$rows = [];
|
||||
|
||||
foreach ($minutesByDay as $day => $minutes) {
|
||||
if ($minutes > 0) {
|
||||
$rows[] = ['task_id' => $taskId, 'user_id' => $userId, 'day' => $day, 'minutes' => $minutes];
|
||||
}
|
||||
}
|
||||
|
||||
if ($rows !== []) {
|
||||
DB::table('task_bookings')->insert($rows);
|
||||
}
|
||||
}
|
||||
|
||||
public function deleteForTask(int $taskId, array $keepUserIds = []): void
|
||||
{
|
||||
DB::table('task_bookings')
|
||||
->where('task_id', $taskId)
|
||||
->when($keepUserIds !== [], fn ($query) => $query->whereNotIn('user_id', $keepUserIds))
|
||||
->delete();
|
||||
}
|
||||
|
||||
public function otherOpenMinutes(int $userId, string $from, string $to, int $exceptTaskId): array
|
||||
{
|
||||
return DB::table('task_bookings')
|
||||
->join('tasks', 'tasks.id', '=', 'task_bookings.task_id')
|
||||
->where('task_bookings.user_id', $userId)
|
||||
->where('task_bookings.task_id', '!=', $exceptTaskId)
|
||||
->where('tasks.status', '!=', TaskStatus::Done->value)
|
||||
->whereBetween('task_bookings.day', [$from, $to])
|
||||
->groupBy('task_bookings.day')
|
||||
->selectRaw('task_bookings.day as day, SUM(task_bookings.minutes) as minutes')
|
||||
->pluck('minutes', 'day')
|
||||
->mapWithKeys(fn ($minutes, $day): array => [substr((string) $day, 0, 10) => (int) $minutes])
|
||||
->all();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user