P2-15~18, P5-04~11, CT-05~06 웹 미구현 기능 전체 구현

P2-15: 지정판매소 다조건 조회 (이름/구군/상태 필터)
P2-17: 지정판매소 지도 표시 (Kakao Maps)
P2-18: 지정판매소 현황 (연도별 신규/취소 통계)
P5-04: 년 판매 현황 (월별 피벗 테이블)
P5-05: 지정판매소별 판매현황 (판매소별 수량/금액)
P5-06: 홈택스 세금계산서 엑셀 내보내기
P5-08: 반품/파기 현황 (기간별 조회)
P5-10: LOT 수불 조회 (LOT 번호 검색)
P5-11: 기타 입출고 (등록 + 재고 연동)
CT-05: CRUD 로깅 (activity_log 테이블 + audit_helper)
CT-06: 대시보드 실 데이터 (발주/판매/재고/불출 통계)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
javamon1174
2026-03-26 16:50:28 +09:00
parent 704141a1f0
commit 1e8bf1eeeb
20 changed files with 1216 additions and 14 deletions

View File

@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
if (! function_exists('audit_log')) {
/**
* CRUD 활동 로그 기록
*
* @param string $action 'create', 'update', 'delete'
* @param string $table 대상 테이블명
* @param int $recordId 대상 레코드 PK
* @param array|null $before 변경 전 데이터 (update/delete 시)
* @param array|null $after 변경 후 데이터 (create/update 시)
*/
function audit_log(string $action, string $table, int $recordId, ?array $before = null, ?array $after = null): void
{
try {
$db = \Config\Database::connect();
// 테이블 존재 여부 확인 (없으면 skip)
if ($db->query("SHOW TABLES LIKE 'activity_log'")->getNumRows() === 0) {
return;
}
$mbIdx = session()->get('mb_idx');
$ip = service('request')->getIPAddress();
model(\App\Models\ActivityLogModel::class)->insert([
'al_mb_idx' => $mbIdx ? (int) $mbIdx : null,
'al_action' => $action,
'al_table' => $table,
'al_record_id' => $recordId,
'al_data_before' => $before !== null ? json_encode($before, JSON_UNESCAPED_UNICODE) : null,
'al_data_after' => $after !== null ? json_encode($after, JSON_UNESCAPED_UNICODE) : null,
'al_ip' => $ip,
'al_regdate' => date('Y-m-d H:i:s'),
]);
} catch (\Throwable $e) {
// 로깅 실패 시 본 로직 방해하지 않음
log_message('error', 'audit_log failed: ' . $e->getMessage());
}
}
}