2026-03-30 15:07:09 +09:00
< ? php
/** @var list<object> $codeKinds */
/** @var array<int,int> $countMap */
2026-04-08 00:20:09 +09:00
/** @var bool $canManageKinds */
2026-04-14 14:49:15 +09:00
/** @var bool $canManageDetails */
/** @var object|null $selectedKind */
/** @var list<object> $detailList */
/** @var array<int,bool> $rowCanEdit */
$canManageKinds = ! empty ( $canManageKinds );
$canManageDetails = ! empty ( $canManageDetails );
$showKindActions = $canManageKinds ;
$selectedKindId = ( int ) ( $selectedKind -> ck_idx ? ? 0 );
$colCount = 6 + ( $showKindActions ? 1 : 0 );
$detailColCount = 7 + ( $canManageDetails ? 1 : 0 );
2026-06-09 14:43:24 +09:00
/** 상태 배지 (업무현황 스타일의 가벼운 pill) */
$stateBadge = static function ( int $state ) : string {
return $state === 1
? '<span class="inline-block px-2 py-0.5 rounded-full text-[11px] font-medium bg-emerald-50 text-emerald-700">사용</span>'
: '<span class="inline-block px-2 py-0.5 rounded-full text-[11px] font-medium bg-gray-100 text-gray-500">미사용</span>' ;
};
2026-03-30 15:07:09 +09:00
?>
2026-04-14 14:49:15 +09:00
< div class = " grid grid-cols-1 xl:grid-cols-2 gap-4 " >
2026-06-09 14:43:24 +09:00
<!-- 기본코드 종류 -->
< section class = " rounded-xl bg-white border border-gray-200 p-4 shadow-sm " >
< div class = " flex flex-wrap items-center justify-between gap-2 mb-3 " >
< h2 class = " text-sm font-bold text-gray-900 " >< i class = " fa-solid fa-layer-group text-blue-600 mr-1 " ></ i > 기본코드 종류 </ h2 >
< ? php if ( $canManageKinds ) : ?>
< a href = " <?= base_url('admin/code-kinds/create') ?> " class = " inline-flex items-center rounded-lg bg-[#243a5e] px-3 py-1.5 text-white text-xs font-semibold shadow-sm hover:opacity-90 " > 기본코드 등록 </ a >
< ? php else : ?>
< span class = " text-gray-400 text-[11px] " > 코드 종류 등록·수정은 super admin·본부 관리자만 가능합니다 .</ span >
< ? php endif ; ?>
2026-03-30 15:07:09 +09:00
</ div >
2026-06-09 14:43:24 +09:00
< div class = " overflow-auto " >
< table class = " w-full text-[13px] " >
< thead >
< tr class = " text-left text-[11px] font-semibold text-gray-500 border-b border-gray-200 " >
< th class = " py-2.5 px-2 w-12 text-center " > 번호 </ th >
< th class = " py-2.5 px-2 w-20 " > 코드 </ th >
< th class = " py-2.5 px-2 " > 코드명 </ th >
< th class = " py-2.5 px-2 w-20 text-center " > 세부코드 </ th >
< th class = " py-2.5 px-2 w-16 text-center " > 상태 </ th >
< th class = " py-2.5 px-2 w-32 " > 등록일 </ th >
< ? php if ( $showKindActions ) : ?>
< th class = " py-2.5 px-2 w-28 text-center " > 작업 </ th >
< ? php endif ; ?>
</ tr >
</ thead >
2026-04-14 14:49:15 +09:00
< tbody >
< ? php if ( ! empty ( $codeKinds )) : ?>
< ? php $i = 0 ; foreach ( $codeKinds as $row ) : $i ++ ; ?>
< ? php
$isSelected = ( int ) $row -> ck_idx === $selectedKindId ;
$detailUrl = base_url ( 'bag/code-kinds?ck_idx=' . ( int ) $row -> ck_idx );
?>
2026-06-09 14:43:24 +09:00
< tr class = " border-b border-gray-200 last:border-0 cursor-pointer hover:bg-blue-50/60 <?= $isSelected ? 'bg-blue-50' : '' ?> "
2026-04-14 14:49:15 +09:00
onclick = " window.location.href='<?= esc( $detailUrl , 'attr') ?>' " >
2026-06-09 14:43:24 +09:00
< td class = " py-2.5 px-2 text-center text-gray-500 " >< ? = ( string ) $i ?> </td>
< td class = " py-2.5 px-2 text-center font-mono text-gray-700 " >< ? = esc ( $row -> ck_code ) ?> </td>
< td class = " py-2.5 px-2 font-medium text-gray-900 " >< ? = esc ( $row -> ck_name ) ?> </td>
< td class = " py-2.5 px-2 text-center text-gray-600 " >< ? = ( int ) ( $countMap [ $row -> ck_idx ] ? ? 0 ) ?> 개</td>
< td class = " py-2.5 px-2 text-center " >< ? = $stateBadge (( int ) ( $row -> ck_state ? ? 0 )) ?> </td>
< td class = " py-2.5 px-2 text-gray-500 text-[12px] " >< ? = esc ( $row -> ck_regdate ? ? '' ) ?> </td>
2026-04-14 14:49:15 +09:00
< ? php if ( $showKindActions ) : ?>
2026-06-09 14:43:24 +09:00
< td class = " py-2.5 px-2 text-center text-xs " onclick = " event.stopPropagation() " >
2026-04-14 14:49:15 +09:00
< a href = " <?= base_url('admin/code-kinds/edit/' . (int) $row->ck_idx ) ?> " class = " text-blue-600 hover:underline mr-1 " > 수정 </ a >
< form action = " <?= base_url('admin/code-kinds/delete/' . (int) $row->ck_idx ) ?> " method = " POST " class = " inline " onsubmit = " return confirm('이 코드 종류를 삭제하시겠습니까?'); " >
< ? = csrf_field () ?>
< button type = " submit " class = " text-red-600 hover:underline " > 삭제 </ button >
</ form >
</ td >
< ? php endif ; ?>
</ tr >
< ? php endforeach ; ?>
< ? php else : ?>
2026-06-09 14:43:24 +09:00
< tr >< td colspan = " <?= (string) $colCount ?> " class = " text-center text-gray-400 py-6 " > 등록된 코드 종류가 없습니다 .</ td ></ tr >
2026-04-14 14:49:15 +09:00
< ? php endif ; ?>
</ tbody >
</ table >
</ div >
</ section >
2026-06-09 14:43:24 +09:00
<!-- 세부코드 -->
< section class = " rounded-xl bg-white border border-gray-200 p-4 shadow-sm " >
< div class = " flex flex-wrap items-center justify-between gap-2 mb-3 " >
< h2 class = " text-sm font-bold text-gray-900 " >
< i class = " fa-solid fa-list-ul text-emerald-600 mr-1 " ></ i > 세부코드
2026-04-14 14:49:15 +09:00
< ? php if ( $selectedKind !== null ) : ?>
2026-06-09 14:43:24 +09:00
< span class = " font-medium text-gray-400 " > — < ? = esc ( $selectedKind -> ck_name ) ?> (<?= esc($selectedKind->ck_code) ?>)</span>
2026-04-14 14:49:15 +09:00
< ? php endif ; ?>
2026-06-09 14:43:24 +09:00
</ h2 >
2026-04-14 14:49:15 +09:00
< ? php if ( $canManageDetails && $selectedKind !== null ) : ?>
2026-06-09 14:43:24 +09:00
< a href = " <?= base_url('admin/code-details/' . (int) $selectedKind->ck_idx . '/create') ?> " class = " inline-flex items-center rounded-lg bg-[#243a5e] px-3 py-1.5 text-white text-xs font-semibold shadow-sm hover:opacity-90 " > 세부코드 등록 </ a >
2026-03-30 15:07:09 +09:00
< ? php endif ; ?>
2026-04-14 14:49:15 +09:00
</ div >
< ? php if ( $selectedKind === null ) : ?>
2026-06-09 14:43:24 +09:00
< div class = " py-10 text-center text-sm text-gray-400 " > 왼쪽에서 코드 종류를 선택해 주세요 .</ div >
2026-04-14 14:49:15 +09:00
< ? php else : ?>
2026-06-09 14:43:24 +09:00
< div class = " overflow-auto " >
< table class = " w-full text-[13px] " >
2026-04-14 14:49:15 +09:00
< thead >
2026-06-09 14:43:24 +09:00
< tr class = " text-left text-[11px] font-semibold text-gray-500 border-b border-gray-200 " >
< th class = " py-2.5 px-2 w-12 text-center " > 번호 </ th >
< th class = " py-2.5 px-2 w-20 " > 코드 </ th >
< th class = " py-2.5 px-2 " > 코드명 </ th >
< th class = " py-2.5 px-2 w-16 text-center " > 범위 </ th >
< th class = " py-2.5 px-2 w-14 text-center " > 정렬 </ th >
< th class = " py-2.5 px-2 w-16 text-center " > 상태 </ th >
< th class = " py-2.5 px-2 w-32 " > 등록일 </ th >
2026-04-14 14:49:15 +09:00
< ? php if ( $canManageDetails ) : ?>
2026-06-09 14:43:24 +09:00
< th class = " py-2.5 px-2 w-24 text-center " > 작업 </ th >
2026-04-14 14:49:15 +09:00
< ? php endif ; ?>
</ tr >
</ thead >
< tbody >
< ? php if ( ! empty ( $detailList )) : ?>
2026-06-01 16:15:15 +09:00
< ? php $dNo = 0 ; foreach ( $detailList as $row ) : $dNo ++ ; ?>
2026-04-14 14:49:15 +09:00
< ? php
$isPlatform = (( $row -> cd_source ? ? 'platform' ) === 'platform' && ( int ) ( $row -> cd_lg_idx ? ? 0 ) === 0 );
$scopeLabel = $isPlatform ? '공통' : '지자체' ;
?>
2026-06-09 14:43:24 +09:00
< tr class = " border-b border-gray-200 last:border-0 hover:bg-gray-50 " >
< td class = " py-2.5 px-2 text-center text-gray-500 " >< ? = ( string ) $dNo ?> </td>
< td class = " py-2.5 px-2 text-center font-mono text-gray-700 " >< ? = esc ( $row -> cd_code ) ?> </td>
< td class = " py-2.5 px-2 font-medium text-gray-900 " >< ? = esc ( $row -> cd_name ) ?> </td>
< td class = " py-2.5 px-2 text-center " >
< span class = " inline-block px-2 py-0.5 rounded-full text-[11px] font-medium <?= $isPlatform ? 'bg-blue-50 text-blue-700' : 'bg-amber-50 text-amber-700' ?> " >< ? = esc ( $scopeLabel ) ?> </span>
</ td >
< td class = " py-2.5 px-2 text-center text-gray-600 " >< ? = ( int ) ( $row -> cd_sort ? ? 0 ) ?> </td>
< td class = " py-2.5 px-2 text-center " >< ? = $stateBadge (( int ) ( $row -> cd_state ? ? 0 )) ?> </td>
< td class = " py-2.5 px-2 text-gray-500 text-[12px] " >< ? = esc ( $row -> cd_regdate ? ? '' ) ?> </td>
2026-04-14 14:49:15 +09:00
< ? php if ( $canManageDetails ) : ?>
2026-06-09 14:43:24 +09:00
< td class = " py-2.5 px-2 text-center text-xs " >
2026-04-14 14:49:15 +09:00
< ? php if ( ! empty ( $rowCanEdit [ $row -> cd_idx ])) : ?>
< a href = " <?= base_url('admin/code-details/edit/' . (int) $row->cd_idx ) ?> " class = " text-blue-600 hover:underline " > 수정 </ a >
< form action = " <?= base_url('admin/code-details/delete/' . (int) $row->cd_idx ) ?> " method = " POST " class = " ml-1 inline " onsubmit = " return confirm('이 세부코드를 삭제하시겠습니까?'); " >
< ? = csrf_field () ?>
< button type = " submit " class = " text-red-600 hover:underline " > 삭제 </ button >
</ form >
< ? php else : ?>
< span class = " text-gray-400 " > — </ span >
< ? php endif ; ?>
</ td >
< ? php endif ; ?>
</ tr >
< ? php endforeach ; ?>
< ? php else : ?>
2026-06-09 14:43:24 +09:00
< tr >< td colspan = " <?= (string) $detailColCount ?> " class = " text-center text-gray-400 py-6 " > 등록된 세부코드가 없습니다 .</ td ></ tr >
2026-04-14 14:49:15 +09:00
< ? php endif ; ?>
</ tbody >
</ table >
</ div >
< ? php endif ; ?>
2026-03-30 15:07:09 +09:00
</ section >
</ div >