diff --git a/app/Controllers/Home.php b/app/Controllers/Home.php index a2fc687..8cf7e3a 100644 --- a/app/Controllers/Home.php +++ b/app/Controllers/Home.php @@ -104,6 +104,34 @@ class Home extends BaseController $pendingApprovals = 0; } + // 지도용 — 현재 지자체 지정판매소(이름·주소). 좌표는 클라이언트(카카오 지오코딩)에서 변환. + $mapShops = []; + try { + if ($lgIdx !== null && $db->tableExists('designated_shop')) { + $rows = $db->table('designated_shop') + ->select('ds_name, ds_addr, ds_addr_jibun') + ->where('ds_lg_idx', $lgIdx) + ->where('ds_addr IS NOT NULL') + ->where('ds_addr <>', '') + ->orderBy('ds_idx', 'ASC') + ->limit(40) + ->get()->getResultArray(); + foreach ($rows as $r) { + $addr = trim((string) ($r['ds_addr'] ?? '')); + if ($addr === '') { + continue; + } + $mapShops[] = [ + 'name' => (string) ($r['ds_name'] ?? ''), + 'addr' => $addr, + 'jibun' => trim((string) ($r['ds_addr_jibun'] ?? '')), + ]; + } + } + } catch (\Throwable $e) { + $mapShops = []; + } + // 최근 활동(activity_log) — 실제 변경 이력 $actionLabel = ['create' => '등록', 'update' => '수정', 'delete' => '삭제', 'cancel' => '취소']; $tableLabel = [ @@ -142,9 +170,44 @@ class Home extends BaseController 'stockMix' => $stockMix, 'lowStock' => $lowStock, 'recentActivity' => $recent, + 'mapShops' => $mapShops, + 'kakaoJsKey' => config(\Config\Kakao::class)->javascriptKey, + 'menuSearchOptions' => (function_exists('gov_portal_nav_context') && function_exists('gov_portal_menu_search_options')) + ? gov_portal_menu_search_options(gov_portal_nav_context(false)['navItems']) + : [], + 'menuFlat' => $this->buildMenuFlat(), ]; } + /** + * 메뉴검색 자동완성용 — 사이트 메뉴를 (상위·메뉴명·URL) 평탄 목록으로. + * + * @return list + */ + private function buildMenuFlat(): array + { + if (! function_exists('gov_portal_nav_context')) { + return []; + } + $flat = []; + foreach (gov_portal_nav_context(false)['navItems'] as $parent) { + $pName = (string) ($parent['name'] ?? ''); + if (! empty($parent['children'])) { + foreach ($parent['children'] as $child) { + $url = (string) ($child['url'] ?? ''); + if ($url === '') { + continue; + } + $flat[] = ['parent' => $pName, 'name' => (string) ($child['name'] ?? ''), 'url' => $url]; + } + } elseif (! empty($parent['url'])) { + $flat[] = ['parent' => '', 'name' => $pName, 'url' => (string) $parent['url']]; + } + } + + return $flat; + } + /** * 로그인 후 메인 — site 메뉴 레이아웃 + 종합·그래프(blend) 본문 */ @@ -376,9 +439,14 @@ class Home extends BaseController protected function resolveLgLabel(): string { try { - $idx = session()->get('mb_lg_idx'); - if ($idx === null || $idx === '') { - return '로그인 지자체 (미지정)'; + helper('admin'); + $idx = function_exists('admin_effective_lg_idx') ? admin_effective_lg_idx() : null; + if ($idx === null) { + $raw = session()->get('mb_lg_idx'); + $idx = ($raw !== null && $raw !== '') ? (int) $raw : null; + } + if ($idx === null) { + return '지자체 미지정'; } $row = model(LocalGovernmentModel::class)->find((int) $idx); if ($row && isset($row->lg_name) && $row->lg_name !== '') { @@ -388,7 +456,7 @@ class Home extends BaseController // 테이블 미생성 등 } - return '북구 (데모)'; + return '지자체'; } } diff --git a/app/Views/bag/_dashboard_kakao_map.php b/app/Views/bag/_dashboard_kakao_map.php new file mode 100644 index 0000000..4e29601 --- /dev/null +++ b/app/Views/bag/_dashboard_kakao_map.php @@ -0,0 +1,194 @@ + $mapShops + */ +$kakaoJsKey = (string) ($kakaoJsKey ?? ''); +$lgLabel = (string) ($lgLabel ?? ''); +$mapShops = is_array($mapShops ?? null) ? $mapShops : []; +$mapId = 'mainKakaoMap'; +?> +
+
+

지정판매소 위치 (곳)

+
+ +
+ +
+ + +
+ +

표시할 지정판매소가 없습니다.

+ +
    + $shop): ?> +
  • + +
  • + +
+ +
+
+ + +
카카오맵 키가 설정되지 않아 지도를 표시할 수 없습니다.
+ +
+ + + + diff --git a/app/Views/bag/dashboard_portal.php b/app/Views/bag/dashboard_portal.php index 7b277a5..9b1f549 100644 --- a/app/Views/bag/dashboard_portal.php +++ b/app/Views/bag/dashboard_portal.php @@ -64,6 +64,147 @@ $donutCss = $donutStops !== [] ? implode(', ', $donutStops) : '#e5e7eb 0% 100%'; + +
+
+ $kakaoJsKey ?? '', + 'lgLabel' => $lgLabel, + 'mapShops' => $mapShops ?? [], + ]) ?> +
+
+ +
+ 메뉴검색 + + +
+

메뉴명을 입력하면 자동완성에서 선택하거나, 전체 이름 입력 후 Enter 로 이동합니다.

+
+
+
+ + +
diff --git a/app/Views/bag/layout/portal.php b/app/Views/bag/layout/portal.php index 610acf4..8de426d 100644 --- a/app/Views/bag/layout/portal.php +++ b/app/Views/bag/layout/portal.php @@ -137,6 +137,21 @@ tailwind.config = { +