feat: 활동 로그에 엑셀 다운로드/인쇄 기록 추가

- export_*: 모든 엑셀/CSV 다운로드를 'export' 액션으로 자동 기록(파일명 포함)
- 인쇄: 레이아웃 beforeprint beacon → bag/activity/print-log 가 'print' 액션 기록(화면·경로)
- 활동 로그 뷰어에 엑셀 다운로드/인쇄 라벨·배지·필터·요약 추가

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
taekyoungc
2026-06-29 18:39:37 +09:00
parent bf9fbd57a4
commit 0a39668478
9 changed files with 68 additions and 0 deletions

View File

@@ -8,6 +8,22 @@ declare(strict_types=1);
* UTF-8 BOM 포함으로 한글 엑셀 호환성 보장
*/
if (! function_exists('audit_export_log')) {
/**
* 엑셀/CSV 다운로드를 활동 로그에 기록 (누가·무엇을 다운로드).
* 모든 export_* 함수 진입 시 호출 — 실패해도 다운로드에 영향 없음.
*/
function audit_export_log(string $filename): void
{
try {
helper('audit');
audit_log('export', 'export', 0, null, ['파일' => $filename]);
} catch (\Throwable $e) {
// 무시: 로깅 실패가 다운로드를 막지 않도록
}
}
}
if (! function_exists('export_csv')) {
/**
* CSV 파일을 브라우저로 다운로드 전송
@@ -18,6 +34,7 @@ if (! function_exists('export_csv')) {
*/
function export_csv(string $filename, array $headers, array $rows): void
{
audit_export_log($filename);
// 파일명에 .csv 확장자 보장
if (! str_ends_with($filename, '.csv')) {
$filename .= '.csv';
@@ -80,6 +97,7 @@ if (! function_exists('export_excel_2003_xml')) {
*/
function export_excel_2003_xml(string $filename, string $sheetName, array $headers, array $rows, array $topRows = []): void
{
audit_export_log($filename);
$filename = preg_replace('/\.[^.]+$/u', '', $filename) . '.xls';
$safeSheet = str_replace(['/', '\\', '?', '*', '[', ']'], '', $sheetName);
@@ -147,6 +165,7 @@ if (! function_exists('export_excel_2003_xml_workbook')) {
*/
function export_excel_2003_xml_workbook(string $filename, array $sheets): void
{
audit_export_log($filename);
$filename = preg_replace('/\.[^.]+$/u', '', $filename) . '.xls';
$esc = static function (mixed $v): string {
@@ -402,6 +421,7 @@ if (! function_exists('export_bag_flow_report_excel')) {
array $metaLines,
array $reportRows
): void {
audit_export_log($filename);
$baseName = preg_replace('/\.[^.]+$/u', '', $filename);
$baseName = preg_replace('/[^\p{L}\p{N}_\-]+/u', '_', $baseName) ?? 'bag_flow';
$baseName = trim($baseName, '_') !== '' ? trim($baseName, '_') : 'bag_flow';
@@ -452,6 +472,7 @@ if (! function_exists('export_xlsx')) {
*/
function export_xlsx(string $filename, string $sheetName, array $headers, array $rows): void
{
audit_export_log($filename);
$filename = preg_replace('/\.[^.]+$/u', '', $filename) . '.xlsx';
$safeSheet = str_replace(['/', '\\', '?', '*', '[', ']'], '', $sheetName);