Files
jongryangje/app/Views/home/_dashboard_gov_portal_sidebar.php
taekyoungc f624c13b5b feat: 모든 상위메뉴 소메뉴에 아이콘 표시(기본정보관리 방식 확대)
기본정보관리에만 적용되던 사이드바 소메뉴 아이콘을 전체 상위메뉴로 확대.
전화접수·발주·입고·재고·판매·수불·분석·반품/취소·바코드 등 실제 메뉴명에
맞는 Font Awesome 아이콘 키워드 매핑 확장(서버 렌더 + JS 재구성 동일 유지).
2026-07-14 12:09:31 +09:00

123 lines
4.9 KiB
PHP

<?php
declare(strict_types=1);
/** @var list<array> $govNavItems */
/** @var int $govActiveParentIdx */
/** @var string $govActiveChildHref */
$activeParent = $govNavItems[$govActiveParentIdx] ?? $govNavItems[0] ?? null;
$sidebarTitle = $activeParent['name'] ?? 'MY MENU';
$activeChildHref = strtolower(ltrim((string) ($govActiveChildHref ?? ''), '/'));
// 모든 상위메뉴의 소메뉴에 어울리는 아이콘(Font Awesome solid) 매핑 — 이름 키워드 기준(구체적인 것 먼저).
$showSidebarIcons = true;
$sidebarIconFor = static function (string $name): string {
$rules = [
'바코드' => 'fa-barcode',
'스캐너' => 'fa-barcode',
'번호' => 'fa-hashtag',
'판매대장' => 'fa-book',
'대장' => 'fa-book',
'집계표' => 'fa-table-list',
'일계표' => 'fa-table-list',
'수불' => 'fa-right-left',
'입출고' => 'fa-right-left',
'무료' => 'fa-gift',
'반품' => 'fa-rotate-left',
'파기' => 'fa-trash-can',
'신규' => 'fa-chart-column',
'취소' => 'fa-ban',
'발주파일' => 'fa-file-arrow-down',
'발주' => 'fa-cart-shopping',
'입고' => 'fa-dolly',
'재고' => 'fa-warehouse',
'불출' => 'fa-truck-ramp-box',
'전화' => 'fa-phone',
'접수' => 'fa-clipboard-list',
'판매현황' => 'fa-chart-column',
'판매소' => 'fa-store',
'대행소' => 'fa-handshake',
'담당자' => 'fa-user-tie',
'대상자' => 'fa-user-check',
'업체' => 'fa-building',
'단가' => 'fa-won-sign',
'코드' => 'fa-list-ol',
'포장' => 'fa-box',
'계획' => 'fa-clipboard-check',
'실사' => 'fa-clipboard-check',
'분석' => 'fa-chart-line',
'추이' => 'fa-chart-line',
'통계' => 'fa-chart-line',
'홈텍스' => 'fa-file-invoice-dollar',
'판매' => 'fa-cash-register',
'현황' => 'fa-chart-column',
'조회' => 'fa-magnifying-glass',
'대시보드' => 'fa-gauge-high',
'회원' => 'fa-users',
'승인' => 'fa-user-check',
'로그' => 'fa-clock-rotate-left',
'이력' => 'fa-clock-rotate-left',
'메뉴' => 'fa-bars',
'지자체' => 'fa-city',
'문의' => 'fa-comment-dots',
'비밀번호' => 'fa-key',
'설정' => 'fa-gear',
'관리' => 'fa-folder-open',
];
foreach ($rules as $kw => $icon) {
if (mb_stripos($name, $kw) !== false) {
return $icon;
}
}
if (stripos($name, 'password') !== false) {
return 'fa-key';
}
return 'fa-angle-right';
};
?>
<aside class="sidebar">
<div class="my-menu-hd" id="portalSidebarTitle"><?= esc($sidebarTitle) ?></div>
<ul class="my-menu-list" id="portalSidebarList">
<?php if ($activeParent !== null): ?>
<?php if (! empty($activeParent['hasChildren'])): ?>
<?php foreach ($activeParent['children'] as $ci => $child): ?>
<?php
$childHref = strtolower(ltrim((string) ($child['href'] ?? ''), '/'));
$isChildActive = $activeChildHref !== ''
? ($childHref === $activeChildHref)
: ($ci === 0);
?>
<li>
<?php if ($child['href'] !== ''): ?>
<a href="<?= esc($child['url']) ?>" class="<?= $isChildActive ? 'active' : '' ?>">
<?php if ($showSidebarIcons): ?><i class="fa-solid <?= esc($sidebarIconFor((string) $child['name']), 'attr') ?>" style="width:1.15em;margin-right:.45em;opacity:.85;"></i><?php endif; ?><?= esc($child['name']) ?>
</a>
<?php else: ?>
<span class="menu-sub" style="opacity:.65;cursor:default;">
<?php if ($showSidebarIcons): ?><i class="fa-solid <?= esc($sidebarIconFor((string) $child['name']), 'attr') ?>" style="width:1.15em;margin-right:.45em;opacity:.85;"></i><?php endif; ?><?= esc($child['name']) ?>
</span>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php elseif ($activeParent['href'] !== ''): ?>
<li>
<a href="<?= esc($activeParent['url']) ?>" class="active">
<?= esc($activeParent['name']) ?>
</a>
</li>
<?php endif; ?>
<?php endif; ?>
</ul>
<div class="sidebar-blocks">
<div class="sb-teal">
<i class="fa-solid fa-mobile-screen"></i>
모바일 앱(예정)<br/>지정판매소 판매·스캔 연동
</div>
<div class="sb-gray">
<i class="fa-solid fa-repeat"></i> 통합 전환<br/>
<a href="<?= base_url('admin/select-local-government') ?>" style="color:#fff;text-decoration:underline;">지자체 선택</a>
</div>
<div class="sb-links">
<a href="<?= base_url('bag/manual') ?>">사용자 매뉴얼</a>
</div>
</div>
</aside>