專案統計儀表板
{{-- ① 總覽列:總數 / 進行中 / 已結束 --}}
{{ $stats['active'] }}
開啟中
{{ $stats['closed'] }}
已結束
{{-- ② 分類細分:産品 / 專案,各自展示開発・保固・維護 --}}
@php
$catMeta = [
'產品' => ['icon' => 'bi-box-seam', 'grad' => '#d97706,#f59e0b', 'param' => 'category'],
'專案' => ['icon' => 'bi-folder-fill', 'grad' => '#2563eb,#60a5fa', 'param' => 'category'],
];
$bsHex = [
'primary' => '#0a58ca', 'success' => '#146c43', 'warning' => '#997404',
'danger' => '#b02a37', 'info' => '#055160', 'secondary'=> '#495057',
'dark' => '#212529',
];
$typeIconMap = [
'開發' => 'bi-tools', '保固' => 'bi-shield-check',
'維護' => 'bi-wrench', '其他' => 'bi-folder2',
];
$allTypeMeta = [];
foreach ($projectTypes as $pt) {
$allTypeMeta[$pt->label] = [
'icon' => $typeIconMap[$pt->label] ?? 'bi-tag',
'color' => $bsHex[$pt->color] ?? '#495057',
'scope' => $pt->scope,
];
}
$categories = collect($catMeta)->keys()
->filter(fn($cat) => ($stats['byCategory'][$cat] ?? 0) > 0);
@endphp
@if($categories->isNotEmpty())
@foreach($categories as $cat)
@php
$cm = $catMeta[$cat];
$catTotal = $stats['byCategory'][$cat] ?? 0;
$catTypes = $stats['byCatType'][$cat] ?? collect();
@endphp
{{-- 分類標頭 --}}
{{ $cat }}
{{ $catTotal }}
{{-- 階段細分 --}}
@foreach($allTypeMeta as $typeName => $tm)
@php
$cnt = $catTypes[$typeName] ?? 0;
$catScope = $cat === '產品' ? 'product' : 'project';
$scopeOk = $tm['scope'] === 'both' || $tm['scope'] === $catScope;
@endphp
@if($scopeOk && ($typeName !== '其他' || $cnt > 0))
@endif
@endforeach
@endforeach
@endif
{{-- ③ 開發工具 --}}
💻 開發框架
@php
$toolMeta = [
'SMF' => ['color' => '#e0ccff', 'icon' => 'bi-terminal'],
'Laravel' => ['color' => '#f5c6cb', 'icon' => 'bi-layers-fill'],
'WordPress' => ['color' => '#d0e2ff', 'icon' => 'bi-wordpress'],
'Wordpress' => ['color' => '#d0e2ff', 'icon' => 'bi-wordpress'],
'ZF2' => ['color' => '#c7eed8', 'icon' => 'bi-bootstrap'],
'其他' => ['color' => '#e2e3e5', 'icon' => 'bi-question-circle'],
];
$allTools = \App\Models\ProjectDevTool::labels();
@endphp
@foreach ($allTools as $toolName)
@php $meta = $toolMeta[$toolName] ?? ['color' => '#e2e3e5', 'icon' => 'bi-tools']; @endphp
@endforeach
{{-- 專案列表(Redmine 風格階層表格) --}}
@php
$allProjects = $projects->getCollection();
$projectMap = $allProjects->keyBy('id');
// 根專案:parent_id 為 null,或父專案不在目前結果集(例如被篩選掉)
$rootProjects = $allProjects->filter(
fn($p) => is_null($p->parent_id) || !$projectMap->has($p->parent_id)
);
// 依客戶分組,按 clientScore 排序(全結束客戶排最後,未分類排次後)
$typeRankView = ['產品' => 1, '結束' => 99];
foreach ($projectTypes as $i => $t) { $typeRankView[$t->label] = $i + 2; }
$byClient = $rootProjects
->sortBy(function ($p) use ($clientScore) {
$score = $clientScore[(string)($p->client_id ?? 'null')] ?? 9;
$name = $p->client?->name ?? 'zzzzz';
return sprintf('%02d_%s', $score, $name);
})
->groupBy(fn($p) => $p->client?->name ?? '⚠ 未分類');
@endphp
@if ($projects->isEmpty())