diff --git a/app/Http/Controllers/DailyLogController.php b/app/Http/Controllers/DailyLogController.php index 3a69e567..df909ff0 100644 --- a/app/Http/Controllers/DailyLogController.php +++ b/app/Http/Controllers/DailyLogController.php @@ -3,6 +3,8 @@ namespace App\Http\Controllers; use App\Models\Admin\AdminPmDailyLogEntry; +use App\Models\Admin\AdminPmIssue; +use App\Models\Admin\AdminPmTask; use App\Services\ProjectManagement\DailyLogService; use App\Services\ProjectManagement\ProjectService; use Illuminate\View\View; @@ -29,6 +31,12 @@ public function index(): View $entryStatuses = AdminPmDailyLogEntry::getStatuses(); $assignees = $this->dailyLogService->getAssigneeList($tenantId); + // 주의 필요 이슈 조회 (마감초과, 마감임박, 긴급) + $attentionIssues = $this->getAttentionIssues(); + + // 주의 필요 태스크 조회 (마감초과, 마감임박, 긴급) + $attentionTasks = $this->getAttentionTasks(); + return view('daily-logs.index', compact( 'projects', 'stats', @@ -36,10 +44,92 @@ public function index(): View 'pendingEntries', 'assigneeTypes', 'entryStatuses', - 'assignees' + 'assignees', + 'attentionIssues', + 'attentionTasks' )); } + /** + * 주의 필요 이슈 조회 + * - 마감일 지난 것 (overdue) + * - 이번 주 마감 예정 (이번 주 월~일) + * - 긴급 표시된 것 + */ + private function getAttentionIssues(): array + { + $today = now()->startOfDay(); + $weekEnd = now()->endOfWeek(); // 이번 주 일요일 + + $issues = AdminPmIssue::with(['project', 'assignee', 'department']) + ->whereIn('status', [AdminPmIssue::STATUS_OPEN, AdminPmIssue::STATUS_IN_PROGRESS]) + ->where(function ($q) use ($today, $weekEnd) { + // 마감일 지난 것 (overdue) + $q->where(function ($q2) use ($today) { + $q2->whereNotNull('due_date') + ->where('due_date', '<', $today); + }) + // 이번 주 마감 예정 + ->orWhere(function ($q2) use ($today, $weekEnd) { + $q2->whereNotNull('due_date') + ->whereBetween('due_date', [$today, $weekEnd]); + }) + // 긴급 표시 + ->orWhere('is_urgent', true); + }) + ->orderByRaw("CASE WHEN due_date < CURDATE() THEN 0 ELSE 1 END") // 마감초과 우선 + ->orderBy('is_urgent', 'desc') + ->orderBy('due_date') + ->get(); + + return [ + 'items' => $issues, + 'overdue_count' => $issues->filter(fn ($i) => $i->due_status === 'overdue')->count(), + 'due_soon_count' => $issues->filter(fn ($i) => $i->due_status === 'due_soon' || ($i->due_date && $i->due_date->lte($weekEnd) && $i->due_date->gte($today)))->count(), + 'urgent_count' => $issues->filter(fn ($i) => $i->is_urgent)->count(), + ]; + } + + /** + * 주의 필요 태스크 조회 + * - 마감일 지난 것 (overdue) + * - 이번 주 마감 예정 (이번 주 월~일) + * - 긴급 표시된 것 + */ + private function getAttentionTasks(): array + { + $today = now()->startOfDay(); + $weekEnd = now()->endOfWeek(); // 이번 주 일요일 + + $tasks = AdminPmTask::with(['project', 'assignee']) + ->where('status', '!=', AdminPmTask::STATUS_DONE) + ->where(function ($q) use ($today, $weekEnd) { + // 마감일 지난 것 (overdue) + $q->where(function ($q2) use ($today) { + $q2->whereNotNull('due_date') + ->where('due_date', '<', $today); + }) + // 이번 주 마감 예정 + ->orWhere(function ($q2) use ($today, $weekEnd) { + $q2->whereNotNull('due_date') + ->whereBetween('due_date', [$today, $weekEnd]); + }) + // 긴급 표시 + ->orWhere('is_urgent', true); + }) + ->orderByRaw("CASE WHEN due_date < CURDATE() THEN 0 ELSE 1 END") + ->orderBy('is_urgent', 'desc') + ->orderBy('due_date') + ->get(); + + return [ + 'items' => $tasks, + 'overdue_count' => $tasks->filter(fn ($t) => $t->due_status === 'overdue')->count(), + 'due_soon_count' => $tasks->filter(fn ($t) => $t->due_date && $t->due_date->lte($weekEnd) && $t->due_date->gte($today))->count(), + 'urgent_count' => $tasks->filter(fn ($t) => $t->is_urgent)->count(), + ]; + } + /** * 일일 로그 상세 화면 */ diff --git a/resources/views/daily-logs/index.blade.php b/resources/views/daily-logs/index.blade.php index 30b61fc4..c445d4d3 100644 --- a/resources/views/daily-logs/index.blade.php +++ b/resources/views/daily-logs/index.blade.php @@ -110,6 +110,252 @@ class="day-card w-full text-left p-3 rounded-lg border-2 transition-all hover:sh + +@if($attentionIssues['items']->count() > 0 || $attentionTasks['items']->count() > 0) +