메인 대시보드에 지정판매소 지도·메뉴검색을 추가한다.
- 카카오 지도(지도 2/3 + 판매소 목록 1/3, 높이 고정·스크롤), 목록 클릭 시 줌인 - 지오코딩 폴백(정밀→도로명→지번→키워드→행정동)으로 마커 표시 - 메뉴검색: 자동완성 드롭다운 + 기본 "최근 방문 메뉴"(localStorage, 뒤로가기/bfcache 갱신) - 메뉴검색 박스 녹색(#009688), 지도와 높이 일치 - resolveLgLabel: 선택 지자체 실제 이름 사용, '(데모)' 문구 제거 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -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<array{parent:string,name:string,url:string}>
|
||||
*/
|
||||
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 '지자체';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user