Initial intranet dashboard app
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
.venv/
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
# 인트라넷 게시판 초보자 가이드
|
||||||
|
|
||||||
|
이 프로젝트는 `WSL2 Ubuntu + VS Code` 환경에서 실행하는 사내 게시판입니다.
|
||||||
|
중요한 점은, `WSL2`에서는 앱을 `0.0.0.0:8010`으로 띄워도 다른 PC가 곧바로 WSL 주소로 접속되지 않을 수 있다는 점입니다.
|
||||||
|
|
||||||
|
즉, 내부망 공유를 하려면 아래 2가지가 모두 필요합니다.
|
||||||
|
|
||||||
|
1. WSL 안에서 FastAPI 서버 실행
|
||||||
|
2. Windows가 `8010` 요청을 받아 WSL의 `8010`으로 전달하도록 설정
|
||||||
|
|
||||||
|
## 1. 이번에 정리된 내용
|
||||||
|
|
||||||
|
- 앱은 [main.py](/home/b17301/my-intranet-app/main.py) 에서 `0.0.0.0:8010`으로 실행됨
|
||||||
|
- 데이터는 `data.db`에 저장됨
|
||||||
|
- WSL2 내부망 공유용 보조 스크립트를 `scripts/` 폴더에 추가함
|
||||||
|
- Windows `portproxy`와 방화벽 규칙 설정용 PowerShell 스크립트를 추가함
|
||||||
|
|
||||||
|
## 2. 폴더 구조
|
||||||
|
|
||||||
|
```text
|
||||||
|
my-intranet-app/
|
||||||
|
├── main.py
|
||||||
|
├── requirements.txt
|
||||||
|
├── data.db
|
||||||
|
├── static/
|
||||||
|
├── templates/
|
||||||
|
│ └── index.html
|
||||||
|
└── scripts/
|
||||||
|
├── run_server.sh
|
||||||
|
├── show_access_info.sh
|
||||||
|
├── setup_windows_portproxy.ps1
|
||||||
|
└── remove_windows_portproxy.ps1
|
||||||
|
```
|
||||||
|
|
||||||
|
## 3. 왜 다른 PC에서 접속이 안 되었는가
|
||||||
|
|
||||||
|
당신의 현재 환경은 `WSL2`입니다.
|
||||||
|
|
||||||
|
WSL2는 Windows 안에 있는 별도 가상 네트워크를 사용합니다.
|
||||||
|
그래서 아래처럼 동작할 수 있습니다.
|
||||||
|
|
||||||
|
- 내 PC 브라우저에서 `http://127.0.0.1:8010` 접속: 됨
|
||||||
|
- 다른 PC에서 `http://WSL-IP:8010` 접속: 안 될 수 있음
|
||||||
|
|
||||||
|
이럴 때는 다른 PC가 `Windows 호스트 IP:8010` 으로 접속하고,
|
||||||
|
Windows가 그 요청을 WSL 앱으로 넘겨줘야 합니다.
|
||||||
|
|
||||||
|
## 4. 처음 한 번만 할 설정
|
||||||
|
|
||||||
|
프로젝트 폴더로 이동:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd /home/b17301/my-intranet-app
|
||||||
|
```
|
||||||
|
|
||||||
|
가상환경 생성:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python3 -m venv .venv
|
||||||
|
```
|
||||||
|
|
||||||
|
가상환경 활성화:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
source .venv/bin/activate
|
||||||
|
```
|
||||||
|
|
||||||
|
라이브러리 설치:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
pip install -r requirements.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
## 5. WSL에서 서버 실행
|
||||||
|
|
||||||
|
아래 명령으로 실행:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./scripts/run_server.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
또는 기존처럼:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
source .venv/bin/activate
|
||||||
|
python main.py
|
||||||
|
```
|
||||||
|
|
||||||
|
내 PC 테스트 주소:
|
||||||
|
|
||||||
|
```text
|
||||||
|
http://127.0.0.1:8010
|
||||||
|
```
|
||||||
|
|
||||||
|
중요:
|
||||||
|
|
||||||
|
- 이제 서버는 `reload=False`로 실행되므로, 예전처럼 자동 재시작 로그가 반복해서 나오지 않습니다.
|
||||||
|
- 코드를 수정한 뒤 반영하려면 서버를 `Ctrl + C`로 끄고 다시 `./scripts/run_server.sh`를 실행하면 됩니다.
|
||||||
|
|
||||||
|
## 6. 현재 WSL 쪽 주소 확인
|
||||||
|
|
||||||
|
아래 명령 실행:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
./scripts/show_access_info.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
현재 값은 실행 시점마다 달라질 수 있습니다.
|
||||||
|
|
||||||
|
- WSL 내부 IP: `./scripts/show_access_info.sh` 실행 결과를 확인
|
||||||
|
- Windows와 연결된 주소 추정값: `./scripts/show_access_info.sh` 실행 결과를 확인
|
||||||
|
|
||||||
|
하지만 다른 PC가 접속할 때는 보통 `WSL 내부 IP`가 아니라 `Windows 호스트 IP`를 사용해야 합니다.
|
||||||
|
|
||||||
|
## 7. 가장 중요한 설정: Windows 포트 전달
|
||||||
|
|
||||||
|
다음 작업은 `Windows PowerShell을 관리자 권한`으로 열어서 실행해야 합니다.
|
||||||
|
|
||||||
|
가장 쉬운 방법은 `PowerShell`에서 아래 명령을 실행하는 것입니다.
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
& "\\wsl$\Ubuntu\home\b17301\my-intranet-app\scripts\setup_windows_portproxy.ps1" -Port 8010
|
||||||
|
```
|
||||||
|
|
||||||
|
만약 `CMD` 창만 사용하고 있다면 아래 명령을 그대로 실행하면 됩니다.
|
||||||
|
|
||||||
|
```cmd
|
||||||
|
"\\wsl$\Ubuntu\home\b17301\my-intranet-app\scripts\setup_windows_portproxy.cmd"
|
||||||
|
```
|
||||||
|
|
||||||
|
이 스크립트가 하는 일:
|
||||||
|
|
||||||
|
- Windows의 `0.0.0.0:8010` 수신
|
||||||
|
- 들어온 요청을 `현재 WSL IP:8010` 으로 전달
|
||||||
|
- Windows 방화벽에서 TCP `8010` 허용
|
||||||
|
|
||||||
|
## 8. 다른 PC에서 접속할 주소
|
||||||
|
|
||||||
|
다른 PC 브라우저에서는 아래처럼 접속합니다.
|
||||||
|
|
||||||
|
```text
|
||||||
|
http://Windows호스트IP:8010
|
||||||
|
```
|
||||||
|
|
||||||
|
예를 들어 Windows PC의 실제 사내 IP가 `192.168.0.25` 라면:
|
||||||
|
|
||||||
|
```text
|
||||||
|
http://192.168.0.25:8010
|
||||||
|
```
|
||||||
|
|
||||||
|
여기서 중요한 점:
|
||||||
|
|
||||||
|
- WSL 주소를 다른 PC에 알려주면 안 될 수 있음
|
||||||
|
- 다른 PC에는 반드시 `Windows IP`를 알려주는 쪽이 안전함
|
||||||
|
|
||||||
|
## 9. WSL IP가 바뀌면 어떻게 하나
|
||||||
|
|
||||||
|
WSL을 재시작하면 내부 IP가 바뀔 수 있습니다.
|
||||||
|
그럴 때는 아래 순서로 다시 맞추면 됩니다.
|
||||||
|
|
||||||
|
1. WSL에서 `./scripts/show_access_info.sh` 실행
|
||||||
|
2. 새 WSL IP 확인
|
||||||
|
3. 관리자 PowerShell에서 다시 실행
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
.\setup_windows_portproxy.ps1 -Port 8010
|
||||||
|
```
|
||||||
|
|
||||||
|
## 10. 접속 확인 순서
|
||||||
|
|
||||||
|
1. WSL에서 `./scripts/run_server.sh` 실행
|
||||||
|
2. 내 PC 브라우저에서 `http://127.0.0.1:8010` 확인
|
||||||
|
3. Windows 관리자 PowerShell에서 `setup_windows_portproxy.ps1` 실행
|
||||||
|
4. 다른 PC에서 `http://Windows호스트IP:8010` 접속
|
||||||
|
|
||||||
|
## 11. 안 되면 확인할 것
|
||||||
|
|
||||||
|
1. 서버가 실제로 실행 중인지 확인
|
||||||
|
|
||||||
|
```bash
|
||||||
|
lsof -i :8010
|
||||||
|
```
|
||||||
|
|
||||||
|
2. 다른 프로그램이 `8010`을 이미 사용 중인지 확인
|
||||||
|
3. Windows 방화벽 규칙이 생겼는지 확인
|
||||||
|
4. 회사 네트워크에서 사설 포트 접근이 막히지 않았는지 확인
|
||||||
|
5. WSL IP가 바뀌었는지 확인
|
||||||
|
|
||||||
|
## 12. 제거가 필요할 때
|
||||||
|
|
||||||
|
관리자 PowerShell에서:
|
||||||
|
|
||||||
|
```powershell
|
||||||
|
& "\\wsl$\Ubuntu\home\b17301\my-intranet-app\scripts\remove_windows_portproxy.ps1" -Port 8010
|
||||||
|
```
|
||||||
|
|
||||||
|
또는 `CMD`에서는:
|
||||||
|
|
||||||
|
```cmd
|
||||||
|
"\\wsl$\Ubuntu\home\b17301\my-intranet-app\scripts\remove_windows_portproxy.cmd" 8010
|
||||||
|
```
|
||||||
|
|
||||||
|
## 13. 초보자용 한 줄 요약
|
||||||
|
|
||||||
|
이 프로젝트는 이제 코드 문제는 해결되어 있고, 내부망 공유의 핵심은 `Windows IP:8010 -> WSL 8010` 연결을 Windows에서 열어주는 것입니다.
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
fastapi
|
||||||
|
jinja2
|
||||||
|
openpyxl
|
||||||
|
python-multipart
|
||||||
|
sqlalchemy
|
||||||
|
uvicorn
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
set SCRIPT_DIR=%~dp0
|
||||||
|
set PORT=%~1
|
||||||
|
|
||||||
|
if "%PORT%"=="" set PORT=8010
|
||||||
|
|
||||||
|
powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%remove_windows_portproxy.ps1" -Port %PORT%
|
||||||
|
|
||||||
|
endlocal
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
param(
|
||||||
|
[string]$ListenAddress = "0.0.0.0",
|
||||||
|
[int]$Port = 8010,
|
||||||
|
[string]$RuleName = "MyIntranetApp-8010"
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
netsh interface portproxy delete v4tov4 listenport=$Port listenaddress=$ListenAddress | Out-Null
|
||||||
|
|
||||||
|
$existingRule = Get-NetFirewallRule -DisplayName $RuleName -ErrorAction SilentlyContinue
|
||||||
|
if ($existingRule) {
|
||||||
|
Remove-NetFirewallRule -DisplayName $RuleName | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Removed portproxy and firewall rule for port $Port" -ForegroundColor Yellow
|
||||||
Executable
+14
@@ -0,0 +1,14 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
cd "$(dirname "$0")/.."
|
||||||
|
|
||||||
|
if [ ! -x ".venv/bin/python" ]; then
|
||||||
|
echo "가상환경이 없습니다. 먼저 아래를 실행하세요."
|
||||||
|
echo "python3 -m venv .venv"
|
||||||
|
echo "source .venv/bin/activate"
|
||||||
|
echo "pip install -r requirements.txt"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec ./.venv/bin/python main.py
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
|
||||||
|
set SCRIPT_DIR=%~dp0
|
||||||
|
set WSL_IP=%~1
|
||||||
|
set PORT=%~2
|
||||||
|
|
||||||
|
if not "%WSL_IP%"=="" (
|
||||||
|
echo %WSL_IP% | findstr /R "^[0-9][0-9]*$" >nul
|
||||||
|
if not errorlevel 1 (
|
||||||
|
set PORT=%WSL_IP%
|
||||||
|
set WSL_IP=
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%PORT%"=="" set PORT=8010
|
||||||
|
|
||||||
|
if "%WSL_IP%"=="" (
|
||||||
|
powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%setup_windows_portproxy.ps1" -Port %PORT%
|
||||||
|
) else (
|
||||||
|
powershell -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_DIR%setup_windows_portproxy.ps1" -WslIp %WSL_IP% -Port %PORT%
|
||||||
|
)
|
||||||
|
|
||||||
|
endlocal
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
param(
|
||||||
|
[string]$ListenAddress = "0.0.0.0",
|
||||||
|
[int]$Port = 8010,
|
||||||
|
[string]$WslIp = "",
|
||||||
|
[string]$RuleName = "MyIntranetApp-8010"
|
||||||
|
)
|
||||||
|
|
||||||
|
$ErrorActionPreference = "Stop"
|
||||||
|
|
||||||
|
if ([string]::IsNullOrWhiteSpace($WslIp)) {
|
||||||
|
$detected = wsl.exe hostname -I 2>$null
|
||||||
|
if (-not $detected) {
|
||||||
|
throw "WSL IP를 자동으로 찾지 못했습니다. -WslIp 옵션으로 직접 지정해 주세요."
|
||||||
|
}
|
||||||
|
|
||||||
|
$WslIp = (($detected -split "\s+") | Where-Object { $_ -match '^\d+\.\d+\.\d+\.\d+$' } | Select-Object -First 1)
|
||||||
|
if (-not $WslIp) {
|
||||||
|
throw "WSL IP를 자동으로 파싱하지 못했습니다. -WslIp 옵션으로 직접 지정해 주세요."
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host "Setting Windows portproxy for WSL app..." -ForegroundColor Cyan
|
||||||
|
Write-Host "ListenAddress: $ListenAddress"
|
||||||
|
Write-Host "Port: $Port"
|
||||||
|
Write-Host "WSL IP: $WslIp"
|
||||||
|
|
||||||
|
netsh interface portproxy delete v4tov4 listenport=$Port listenaddress=$ListenAddress | Out-Null
|
||||||
|
netsh interface portproxy add v4tov4 listenport=$Port listenaddress=$ListenAddress connectport=$Port connectaddress=$WslIp
|
||||||
|
|
||||||
|
$existingRule = Get-NetFirewallRule -DisplayName $RuleName -ErrorAction SilentlyContinue
|
||||||
|
if ($existingRule) {
|
||||||
|
Remove-NetFirewallRule -DisplayName $RuleName | Out-Null
|
||||||
|
}
|
||||||
|
|
||||||
|
New-NetFirewallRule `
|
||||||
|
-DisplayName $RuleName `
|
||||||
|
-Direction Inbound `
|
||||||
|
-Action Allow `
|
||||||
|
-Protocol TCP `
|
||||||
|
-LocalPort $Port | Out-Null
|
||||||
|
|
||||||
|
$windowsIps = Get-NetIPAddress -AddressFamily IPv4 |
|
||||||
|
Where-Object { $_.IPAddress -notlike '127.*' -and $_.IPAddress -notlike '169.254*' -and $_.IPAddress -notlike '172.*' } |
|
||||||
|
Select-Object -ExpandProperty IPAddress
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Completed." -ForegroundColor Green
|
||||||
|
Write-Host "Now open this from another PC on the intranet:"
|
||||||
|
Write-Host "http://<Windows-IP>:$Port"
|
||||||
|
if ($windowsIps) {
|
||||||
|
Write-Host "Windows IPv4 candidates: $($windowsIps -join ', ')"
|
||||||
|
}
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "Tip: if WSL restarts and its IP changes, run this script again. If you omit -WslIp, the script will detect it automatically."
|
||||||
Executable
+27
@@ -0,0 +1,27 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
WSL_IP="$(hostname -I | awk '{print $1}')"
|
||||||
|
WSL_HOST_IP="$(awk '/nameserver/ {print $2; exit}' /etc/resolv.conf)"
|
||||||
|
WINDOWS_IPS="$(
|
||||||
|
powershell.exe -NoProfile -Command "(Get-NetIPAddress -AddressFamily IPv4 | Where-Object { \$_.IPAddress -notlike '127.*' -and \$_.IPAddress -notlike '169.254*' } | Select-Object -ExpandProperty IPAddress) -join ','" \
|
||||||
|
2>/dev/null | tr -d '\r'
|
||||||
|
)"
|
||||||
|
|
||||||
|
cat <<EOF
|
||||||
|
WSL 앱 정보
|
||||||
|
- WSL 내부 IP: ${WSL_IP}
|
||||||
|
- Windows 호스트와 연결된 주소 추정값: ${WSL_HOST_IP}
|
||||||
|
- Windows IPv4 후보: ${WINDOWS_IPS:-확인 실패}
|
||||||
|
- 앱 포트: 8010
|
||||||
|
|
||||||
|
중요
|
||||||
|
- WSL2에서는 다른 PC가 WSL 내부 IP(${WSL_IP})로 직접 접속하지 못하는 경우가 많습니다.
|
||||||
|
- 내부망 다른 PC에서는 보통 Windows 호스트 IP:8010 으로 접속해야 합니다.
|
||||||
|
- 따라서 Windows 관리자 PowerShell에서 portproxy + 방화벽 규칙을 설정해야 합니다.
|
||||||
|
|
||||||
|
다음 단계
|
||||||
|
1. WSL에서 서버 실행: ./scripts/run_server.sh
|
||||||
|
2. Windows 관리자 PowerShell 또는 CMD에서 scripts/setup_windows_portproxy 실행
|
||||||
|
3. 다른 PC 브라우저에서 http://Windows호스트IP:8010 접속
|
||||||
|
EOF
|
||||||
@@ -0,0 +1,437 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}연도별 수익 비용 정리{% endblock %}
|
||||||
|
|
||||||
|
{% block head_extra %}
|
||||||
|
<style>
|
||||||
|
.filter-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 220px 220px 1fr;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.legend {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 10px;
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.legend-item {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
color: #363b44;
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 700;
|
||||||
|
background: rgba(255,255,255,0.92);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 6px 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.legend-swatch {
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-box {
|
||||||
|
background:
|
||||||
|
linear-gradient(180deg, rgba(255,255,255,0.98), rgba(246,247,249,0.98)),
|
||||||
|
radial-gradient(circle at top left, rgba(17, 17, 17, 0.045), transparent 36%);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 16px;
|
||||||
|
box-shadow: inset 0 1px 0 rgba(255,255,255,0.92);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-legend {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-title {
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: 700;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-svg {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
aspect-ratio: 1200 / 420;
|
||||||
|
min-height: 320px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.expense-chart-svg {
|
||||||
|
aspect-ratio: 1600 / 420;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-note {
|
||||||
|
margin-top: 10px;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1000px) {
|
||||||
|
.filter-grid,
|
||||||
|
.metric-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<section class="panel">
|
||||||
|
<div class="section-title">
|
||||||
|
<h2>연도별 수익 비용 정리</h2>
|
||||||
|
</div>
|
||||||
|
<div class="filter-grid">
|
||||||
|
<div class="field">
|
||||||
|
<select id="granularity" aria-label="보기 기준">
|
||||||
|
<option value="yearly">연간</option>
|
||||||
|
<option value="monthly">월간</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<select id="yearFilter" aria-label="연도 선택">
|
||||||
|
<option value="recent10">최근 10개년</option>
|
||||||
|
{% for year in available_years %}
|
||||||
|
<option value="{{ year }}">{{ year }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div></div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="panel">
|
||||||
|
<div class="section-title">
|
||||||
|
<h2>선택 구간 요약</h2>
|
||||||
|
</div>
|
||||||
|
<div class="metric-grid" id="metricGrid"></div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="panel">
|
||||||
|
<div class="section-title">
|
||||||
|
<h2>비용 구조</h2>
|
||||||
|
</div>
|
||||||
|
<div class="chart-box">
|
||||||
|
<div class="legend chart-legend" id="expenseLegend"></div>
|
||||||
|
<svg id="expenseChart" class="chart-svg expense-chart-svg" viewBox="0 0 1600 420" preserveAspectRatio="xMidYMid meet"></svg>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="panel">
|
||||||
|
<div class="section-title">
|
||||||
|
<h2>수익/비용/영업수지 그래프</h2>
|
||||||
|
</div>
|
||||||
|
<div class="chart-box">
|
||||||
|
<div class="legend chart-legend" id="balanceLegend"></div>
|
||||||
|
<svg id="balanceChart" class="chart-svg" viewBox="0 0 1200 420" preserveAspectRatio="xMidYMid meet"></svg>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block script %}
|
||||||
|
<script>
|
||||||
|
const yearlySeries = {{ yearly_financial_series | tojson }};
|
||||||
|
const monthlySeries = {{ monthly_financial_series | tojson }};
|
||||||
|
const availableYears = [...new Set(yearlySeries.map((item) => item.year).filter((year) => year !== null && year !== undefined))];
|
||||||
|
|
||||||
|
const palette = {
|
||||||
|
revenue_sum: "#0f766e",
|
||||||
|
project_cost_sum: "#0ea5a4",
|
||||||
|
support_cost_sum: "#67b7dc",
|
||||||
|
support_sga_sum: "#f59e0b",
|
||||||
|
field_sga_sum: "#f97316",
|
||||||
|
labor_sum: "#8b5cf6",
|
||||||
|
outsourcing_sum: "#ec4899",
|
||||||
|
total_expense: "#1d4ed8",
|
||||||
|
operating_balance: "#dc2626",
|
||||||
|
};
|
||||||
|
|
||||||
|
const labels = {
|
||||||
|
revenue_sum: "수익",
|
||||||
|
project_cost_sum: "원가(프로젝트)",
|
||||||
|
support_cost_sum: "원가(지원부서)",
|
||||||
|
support_sga_sum: "판관비(지원부서)",
|
||||||
|
field_sga_sum: "판관비(현업부서)",
|
||||||
|
labor_sum: "원가인건비",
|
||||||
|
outsourcing_sum: "원가외주비",
|
||||||
|
total_expense: "비용합계",
|
||||||
|
operating_balance: "영업수지",
|
||||||
|
};
|
||||||
|
|
||||||
|
function formatNumber(value) {
|
||||||
|
return new Intl.NumberFormat("ko-KR", { maximumFractionDigits: 0 }).format(value || 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatAxisLabel(value) {
|
||||||
|
const numeric = Number(value || 0);
|
||||||
|
if (!numeric) return "0.0";
|
||||||
|
if (numeric >= 100000000) return `${(numeric / 100000000).toFixed(1)}억`;
|
||||||
|
if (numeric >= 1000000) return `${(numeric / 1000000).toFixed(1)}백만`;
|
||||||
|
if (numeric >= 1000) return `${(numeric / 1000).toFixed(1)}천`;
|
||||||
|
return formatNumber(numeric);
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickTickStep(maxValue) {
|
||||||
|
const baseUnit = maxValue < 1000000 ? 1000 : 1000000;
|
||||||
|
const units = [1, 2, 5];
|
||||||
|
const raw = Math.max(maxValue / 5 / baseUnit, 1);
|
||||||
|
let power = 1;
|
||||||
|
while (power * 10 <= raw) power *= 10;
|
||||||
|
for (const unit of units) {
|
||||||
|
const candidate = unit * power;
|
||||||
|
if (candidate >= raw) return candidate * baseUnit;
|
||||||
|
}
|
||||||
|
return power * 10 * baseUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderLegend(targetId, keys) {
|
||||||
|
const target = document.getElementById(targetId);
|
||||||
|
if (!target) return;
|
||||||
|
target.innerHTML = keys.map((key) => `
|
||||||
|
<span class="legend-item">
|
||||||
|
<span class="legend-swatch" style="background:${palette[key]};"></span>
|
||||||
|
${labels[key]}
|
||||||
|
</span>
|
||||||
|
`).join("");
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLatestAvailableYear() {
|
||||||
|
return String(availableYears[availableYears.length - 1] || "recent10");
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncYearFilter() {
|
||||||
|
const granularity = document.getElementById("granularity").value;
|
||||||
|
const yearFilterEl = document.getElementById("yearFilter");
|
||||||
|
if (!yearFilterEl) return;
|
||||||
|
|
||||||
|
if (granularity === "yearly") {
|
||||||
|
yearFilterEl.value = "recent10";
|
||||||
|
yearFilterEl.disabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasSelectedYear = availableYears.some((year) => String(year) === String(yearFilterEl.value));
|
||||||
|
if (yearFilterEl.value === "recent10" || !hasSelectedYear) {
|
||||||
|
yearFilterEl.value = getLatestAvailableYear();
|
||||||
|
}
|
||||||
|
yearFilterEl.disabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getFilteredSeries() {
|
||||||
|
const granularity = document.getElementById("granularity").value;
|
||||||
|
const selectedYear = document.getElementById("yearFilter").value;
|
||||||
|
if (granularity === "yearly" || selectedYear === "recent10") {
|
||||||
|
return yearlySeries
|
||||||
|
.slice(-10)
|
||||||
|
.map((item) => ({ ...item, label: String(item.year) }));
|
||||||
|
}
|
||||||
|
return monthlySeries
|
||||||
|
.filter((item) => String(item.year) === String(selectedYear))
|
||||||
|
.map((item) => ({ ...item, label: `${item.month}월` }));
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderMetrics(series) {
|
||||||
|
const keys = [
|
||||||
|
"revenue_sum",
|
||||||
|
"project_cost_sum",
|
||||||
|
"support_cost_sum",
|
||||||
|
"support_sga_sum",
|
||||||
|
"field_sga_sum",
|
||||||
|
"labor_sum",
|
||||||
|
"outsourcing_sum",
|
||||||
|
"total_expense",
|
||||||
|
"operating_balance",
|
||||||
|
];
|
||||||
|
const totals = {};
|
||||||
|
keys.forEach((key) => {
|
||||||
|
totals[key] = series.reduce((sum, item) => sum + (item[key] || 0), 0);
|
||||||
|
});
|
||||||
|
const grid = document.getElementById("metricGrid");
|
||||||
|
grid.innerHTML = keys.map((key) => `
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="label">${labels[key]}</div>
|
||||||
|
<div class="value">${formatNumber(totals[key])}</div>
|
||||||
|
</div>
|
||||||
|
`).join("");
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildAxis(maxValue, width, height, margin) {
|
||||||
|
const tickStep = pickTickStep(maxValue);
|
||||||
|
const tickMax = Math.ceil(maxValue / tickStep) * tickStep;
|
||||||
|
let axis = "";
|
||||||
|
for (let value = 0; value <= tickMax; value += tickStep) {
|
||||||
|
const y = height - margin.bottom - ((height - margin.top - margin.bottom) * value) / tickMax;
|
||||||
|
axis += `<line x1="${margin.left}" y1="${y}" x2="${width - margin.right}" y2="${y}" stroke="#d8dee5" stroke-dasharray="3 7" />`;
|
||||||
|
axis += `<text x="${margin.left - 12}" y="${y + 4}" text-anchor="end" fill="#5a6672" font-size="11" font-weight="700">${formatAxisLabel(value)}</text>`;
|
||||||
|
}
|
||||||
|
axis += `<line x1="${margin.left}" y1="${height - margin.bottom}" x2="${width - margin.right}" y2="${height - margin.bottom}" stroke="#8ba0ae" stroke-width="1.2" />`;
|
||||||
|
return { axis, tickMax };
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderEmptyChart(svgId, message) {
|
||||||
|
const svg = document.getElementById(svgId);
|
||||||
|
if (!svg) return;
|
||||||
|
svg.innerHTML = `
|
||||||
|
<rect x="0" y="0" width="1200" height="420" rx="8" fill="#f7fafb" stroke="#d6e2e8"></rect>
|
||||||
|
<text x="600" y="210" text-anchor="middle" fill="#667887" font-size="18" font-weight="700">${message}</text>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderExpenseChart(series) {
|
||||||
|
const svg = document.getElementById("expenseChart");
|
||||||
|
const keys = ["labor_sum", "outsourcing_sum", "project_cost_sum", "support_cost_sum", "support_sga_sum", "field_sga_sum"];
|
||||||
|
const isMonthlyView = series.some((item) => String(item.label || "").includes("월"));
|
||||||
|
renderLegend("expenseLegend", keys);
|
||||||
|
if (!series.length) {
|
||||||
|
renderEmptyChart("expenseChart", "표시할 비용 구조 데이터가 없습니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const width = 1600;
|
||||||
|
const height = 420;
|
||||||
|
const margin = { top: 30, right: isMonthlyView ? 72 : 36, bottom: 74, left: 98 };
|
||||||
|
const barWidth = (width - margin.left - margin.right) / series.length * (isMonthlyView ? 0.18 : 0.29);
|
||||||
|
const step = (width - margin.left - margin.right) / series.length;
|
||||||
|
const maxValue = Math.max(...series.map((item) => keys.reduce((sum, key) => sum + (item[key] || 0), 0)), 1);
|
||||||
|
const { axis, tickMax } = buildAxis(maxValue, width, height, margin);
|
||||||
|
let markup = `
|
||||||
|
<defs>
|
||||||
|
<filter id="expenseShadow" x="-20%" y="-20%" width="140%" height="160%">
|
||||||
|
<feDropShadow dx="0" dy="8" stdDeviation="8" flood-color="rgba(44, 68, 89, 0.12)" />
|
||||||
|
</filter>
|
||||||
|
</defs>
|
||||||
|
<rect x="${margin.left}" y="${margin.top}" width="${width - margin.left - margin.right}" height="${height - margin.top - margin.bottom}" rx="6" fill="rgba(255,255,255,0.7)" stroke="#dde7ec"></rect>
|
||||||
|
${axis}
|
||||||
|
`;
|
||||||
|
series.forEach((item, index) => {
|
||||||
|
let cumulative = 0;
|
||||||
|
const total = keys.reduce((sum, key) => sum + (item[key] || 0), 0);
|
||||||
|
const x = margin.left + index * step + (step - barWidth) / 2;
|
||||||
|
const detailX = x + barWidth + 8;
|
||||||
|
const labelEntries = [];
|
||||||
|
keys.forEach((key) => {
|
||||||
|
const value = item[key] || 0;
|
||||||
|
const barHeight = ((height - margin.top - margin.bottom) * value) / tickMax;
|
||||||
|
const y = height - margin.bottom - barHeight - ((height - margin.top - margin.bottom) * cumulative) / tickMax;
|
||||||
|
cumulative += value;
|
||||||
|
markup += `<rect x="${x}" y="${y}" width="${barWidth}" height="${barHeight}" rx="2" fill="${palette[key]}" filter="url(#expenseShadow)" />`;
|
||||||
|
if (value > 0) {
|
||||||
|
const percent = total ? ((value / total) * 100).toFixed(1) : "0.0";
|
||||||
|
labelEntries.push({
|
||||||
|
key,
|
||||||
|
value,
|
||||||
|
percent,
|
||||||
|
desiredY: y + (barHeight / 2),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
labelEntries.sort((a, b) => a.desiredY - b.desiredY);
|
||||||
|
const minY = margin.top + 12;
|
||||||
|
const maxY = height - margin.bottom - 12;
|
||||||
|
const gap = isMonthlyView ? 16 : 18;
|
||||||
|
let lastY = minY - gap;
|
||||||
|
labelEntries.forEach((entry) => {
|
||||||
|
const lineY = Math.max(entry.desiredY, lastY + gap, minY);
|
||||||
|
const finalY = Math.min(lineY, maxY);
|
||||||
|
lastY = finalY;
|
||||||
|
markup += `<rect x="${detailX}" y="${finalY - 10}" width="8" height="8" rx="1.5" fill="${palette[entry.key]}"></rect>`;
|
||||||
|
markup += `<text x="${detailX + 14}" y="${finalY + 4}" text-anchor="start" fill="#6b7b88" font-size="9" font-weight="700">${entry.percent}%</text>`;
|
||||||
|
});
|
||||||
|
if (total > 0) {
|
||||||
|
const topY = height - margin.bottom - ((height - margin.top - margin.bottom) * total) / tickMax;
|
||||||
|
markup += `<text x="${x + barWidth / 2}" y="${Math.max(topY - 10, margin.top + 10)}" text-anchor="middle" fill="#314555" font-size="10.5" font-weight="800">${formatAxisLabel(total)}</text>`;
|
||||||
|
}
|
||||||
|
markup += `<text x="${x + barWidth / 2}" y="${height - margin.bottom + 20}" text-anchor="middle" fill="#5a6672" font-size="11.5" font-weight="700">${item.label}</text>`;
|
||||||
|
});
|
||||||
|
svg.innerHTML = markup;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderBalanceChart(series) {
|
||||||
|
const svg = document.getElementById("balanceChart");
|
||||||
|
const metrics = ["revenue_sum", "total_expense", "operating_balance"];
|
||||||
|
renderLegend("balanceLegend", metrics);
|
||||||
|
if (!series.length) {
|
||||||
|
renderEmptyChart("balanceChart", "표시할 수익/비용 데이터가 없습니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const width = 1200;
|
||||||
|
const height = 420;
|
||||||
|
const margin = { top: 30, right: 24, bottom: 74, left: 98 };
|
||||||
|
const plotWidth = width - margin.left - margin.right;
|
||||||
|
const plotHeight = height - margin.top - margin.bottom;
|
||||||
|
const maxValue = Math.max(...series.flatMap((item) => [
|
||||||
|
item.revenue_sum || 0,
|
||||||
|
item.total_expense || 0,
|
||||||
|
Math.abs(item.operating_balance || 0),
|
||||||
|
]), 1);
|
||||||
|
const { axis, tickMax } = buildAxis(maxValue, width, height, margin);
|
||||||
|
const groupWidth = plotWidth / Math.max(series.length, 1);
|
||||||
|
const groupGap = groupWidth * 0.22;
|
||||||
|
const innerGap = 0;
|
||||||
|
const barWidth = Math.min((groupWidth - groupGap * 2) / metrics.length, 44);
|
||||||
|
const actualGroupWidth = barWidth * metrics.length + innerGap * (metrics.length - 1);
|
||||||
|
const groupStartOffset = (groupWidth - actualGroupWidth) / 2;
|
||||||
|
let markup = `
|
||||||
|
<defs>
|
||||||
|
<filter id="balanceShadow" x="-20%" y="-20%" width="140%" height="160%">
|
||||||
|
<feDropShadow dx="0" dy="8" stdDeviation="8" flood-color="rgba(44, 68, 89, 0.12)" />
|
||||||
|
</filter>
|
||||||
|
</defs>
|
||||||
|
<rect x="${margin.left}" y="${margin.top}" width="${plotWidth}" height="${plotHeight}" rx="6" fill="rgba(255,255,255,0.7)" stroke="#dde7ec"></rect>
|
||||||
|
${axis}
|
||||||
|
`;
|
||||||
|
series.forEach((item, index) => {
|
||||||
|
const baseX = margin.left + index * groupWidth;
|
||||||
|
metrics.forEach((key, metricIndex) => {
|
||||||
|
const value = key === "operating_balance" ? Math.abs(item[key] || 0) : (item[key] || 0);
|
||||||
|
const barHeight = (plotHeight * value) / tickMax;
|
||||||
|
const x = baseX + groupStartOffset + metricIndex * (barWidth + innerGap);
|
||||||
|
const y = height - margin.bottom - barHeight;
|
||||||
|
markup += `<rect x="${x}" y="${y}" width="${barWidth}" height="${barHeight}" rx="2" fill="${palette[key]}" filter="url(#balanceShadow)" />`;
|
||||||
|
if (value > 0) {
|
||||||
|
markup += `<text x="${x + barWidth / 2}" y="${Math.max(y - 8, margin.top + 12)}" text-anchor="middle" fill="#314555" font-size="9.5" font-weight="800">${formatAxisLabel(value)}</text>`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
markup += `<text x="${baseX + groupWidth / 2}" y="${height - margin.bottom + 20}" text-anchor="middle" fill="#5a6672" font-size="11.5" font-weight="700">${item.label}</text>`;
|
||||||
|
});
|
||||||
|
|
||||||
|
svg.innerHTML = markup;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderAll() {
|
||||||
|
syncYearFilter();
|
||||||
|
const series = getFilteredSeries();
|
||||||
|
renderMetrics(series);
|
||||||
|
renderExpenseChart(series);
|
||||||
|
renderBalanceChart(series);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById("granularity").addEventListener("change", renderAll);
|
||||||
|
document.getElementById("yearFilter").addEventListener("change", renderAll);
|
||||||
|
const granularitySelect = document.getElementById("granularity");
|
||||||
|
if (granularitySelect) {
|
||||||
|
granularitySelect.value = "yearly";
|
||||||
|
}
|
||||||
|
const yearFilter = document.getElementById("yearFilter");
|
||||||
|
if (yearFilter) {
|
||||||
|
yearFilter.value = "recent10";
|
||||||
|
}
|
||||||
|
renderAll();
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,665 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ko">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>{% block title %}인트라넷 회계 시스템{% endblock %}</title>
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--bg-a: #f6f6f7;
|
||||||
|
--bg-b: #ececef;
|
||||||
|
--panel: rgba(255, 255, 255, 0.94);
|
||||||
|
--ink: #161616;
|
||||||
|
--muted: #73777f;
|
||||||
|
--line: #d9dde3;
|
||||||
|
--accent: #111111;
|
||||||
|
--accent-strong: #000000;
|
||||||
|
--warn: #fff2cb;
|
||||||
|
--table-alt: #f5f6f8;
|
||||||
|
--white: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: "SUIT", "Noto Sans KR", "Malgun Gothic", sans-serif;
|
||||||
|
color: var(--ink);
|
||||||
|
background:
|
||||||
|
radial-gradient(circle at top left, rgba(255, 255, 255, 0.92), transparent 24%),
|
||||||
|
linear-gradient(180deg, var(--bg-a), var(--bg-b));
|
||||||
|
min-height: 100vh;
|
||||||
|
padding: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page {
|
||||||
|
max-width: 1520px;
|
||||||
|
margin: 0 auto;
|
||||||
|
display: grid;
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
background: rgba(255, 255, 255, 0.9);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 18px;
|
||||||
|
padding: 8px;
|
||||||
|
box-shadow: 0 10px 24px rgba(21, 24, 29, 0.06);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav-spacer {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-width: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: var(--ink);
|
||||||
|
padding: 9px 13px;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 14px;
|
||||||
|
transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav a.active {
|
||||||
|
background: var(--accent);
|
||||||
|
color: var(--white);
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav a:hover {
|
||||||
|
background: #f3f4f6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel {
|
||||||
|
background: var(--panel);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 18px;
|
||||||
|
padding: 18px;
|
||||||
|
box-shadow: 0 10px 24px rgba(21, 24, 29, 0.045);
|
||||||
|
backdrop-filter: blur(6px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
margin-bottom: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title h2 {
|
||||||
|
font-size: 21px;
|
||||||
|
letter-spacing: -0.03em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title p {
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message {
|
||||||
|
background: var(--warn);
|
||||||
|
border: 1px solid #ead98a;
|
||||||
|
color: #624c0b;
|
||||||
|
border-radius: 14px;
|
||||||
|
padding: 14px 16px;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 18px;
|
||||||
|
margin-top: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card {
|
||||||
|
background: var(--white);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 14px;
|
||||||
|
padding: 14px 15px 13px;
|
||||||
|
box-shadow: inset 0 1px 0 rgba(255,255,255,0.7);
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card .label {
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 13px;
|
||||||
|
margin-bottom: 6px;
|
||||||
|
letter-spacing: 0.01em;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card .value {
|
||||||
|
font-size: clamp(23px, 2vw, 38px);
|
||||||
|
font-weight: 800;
|
||||||
|
line-height: 1.1;
|
||||||
|
letter-spacing: -0.04em;
|
||||||
|
word-break: break-word;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card .meta {
|
||||||
|
margin-top: 6px;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 1.45;
|
||||||
|
}
|
||||||
|
|
||||||
|
.two-col {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 0.92fr 1.08fr;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stack {
|
||||||
|
display: grid;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
display: grid;
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-box {
|
||||||
|
background: linear-gradient(180deg, #fbfbfc, #f1f3f6);
|
||||||
|
border: 1px dashed #c5ccd6;
|
||||||
|
border-radius: 14px;
|
||||||
|
padding: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-box p {
|
||||||
|
color: var(--muted);
|
||||||
|
line-height: 1.65;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field {
|
||||||
|
display: grid;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-wide {
|
||||||
|
grid-column: span 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-full {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
input,
|
||||||
|
select,
|
||||||
|
textarea,
|
||||||
|
button {
|
||||||
|
font: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="text"],
|
||||||
|
input[type="number"],
|
||||||
|
input[type="date"],
|
||||||
|
input[type="file"],
|
||||||
|
select,
|
||||||
|
textarea {
|
||||||
|
width: 100%;
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
background: #fcfcfd;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 10px 12px;
|
||||||
|
color: var(--ink);
|
||||||
|
box-shadow: inset 0 1px 2px rgba(16, 24, 40, 0.03);
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
min-height: 96px;
|
||||||
|
resize: vertical;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:focus,
|
||||||
|
select:focus,
|
||||||
|
textarea:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--accent);
|
||||||
|
box-shadow: 0 0 0 3px rgba(17, 17, 17, 0.08);
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
button,
|
||||||
|
.button-link {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
border-radius: 10px;
|
||||||
|
border: 1px solid transparent;
|
||||||
|
padding: 9px 14px;
|
||||||
|
background: var(--accent);
|
||||||
|
color: var(--white);
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 14px;
|
||||||
|
cursor: pointer;
|
||||||
|
text-decoration: none;
|
||||||
|
transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
|
||||||
|
box-shadow: 0 8px 18px rgba(17, 17, 17, 0.14);
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover,
|
||||||
|
.button-link:hover {
|
||||||
|
background: var(--accent-strong);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-secondary {
|
||||||
|
background: #ffffff;
|
||||||
|
color: #1b1d21;
|
||||||
|
border-color: var(--line);
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-icon {
|
||||||
|
width: 38px;
|
||||||
|
height: 38px;
|
||||||
|
min-width: 38px;
|
||||||
|
padding: 0;
|
||||||
|
border-radius: 10px;
|
||||||
|
box-shadow: none;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-icon svg {
|
||||||
|
width: 16px;
|
||||||
|
height: 16px;
|
||||||
|
stroke: currentColor;
|
||||||
|
fill: none;
|
||||||
|
stroke-width: 1.8;
|
||||||
|
stroke-linecap: round;
|
||||||
|
stroke-linejoin: round;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-icon.button-secondary svg {
|
||||||
|
stroke: #1b1d21;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-icon.danger-lite svg {
|
||||||
|
stroke: #a93a3a;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sr-only {
|
||||||
|
position: absolute;
|
||||||
|
width: 1px;
|
||||||
|
height: 1px;
|
||||||
|
padding: 0;
|
||||||
|
margin: -1px;
|
||||||
|
overflow: hidden;
|
||||||
|
clip: rect(0, 0, 0, 0);
|
||||||
|
white-space: nowrap;
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-wrap {
|
||||||
|
overflow: auto;
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 14px;
|
||||||
|
background: var(--white);
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
min-width: 780px;
|
||||||
|
}
|
||||||
|
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
padding: 12px 14px;
|
||||||
|
border-bottom: 1px solid var(--line);
|
||||||
|
text-align: left;
|
||||||
|
vertical-align: top;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
background: #eff5f7;
|
||||||
|
color: #345061;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tbody tr:nth-child(even) td {
|
||||||
|
background: var(--table-alt);
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty {
|
||||||
|
padding: 24px;
|
||||||
|
color: var(--muted);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box {
|
||||||
|
margin: 16px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mono {
|
||||||
|
font-family: "Consolas", "Courier New", monospace;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sync-status {
|
||||||
|
margin-left: auto;
|
||||||
|
max-width: 240px;
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 999px;
|
||||||
|
background: rgba(248, 250, 252, 0.92);
|
||||||
|
box-shadow: none;
|
||||||
|
padding: 6px 10px;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
backdrop-filter: blur(6px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sync-status-head {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sync-status-title {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 800;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sync-dot {
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: #9aa3af;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sync-dot.online {
|
||||||
|
background: #16a34a;
|
||||||
|
box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sync-dot.error {
|
||||||
|
background: #dc2626;
|
||||||
|
box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.sync-pill {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sync-meta {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sync-meta strong {
|
||||||
|
color: var(--ink);
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1200px) {
|
||||||
|
.stats {
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-grid,
|
||||||
|
.two-col {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-grid {
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 720px) {
|
||||||
|
body {
|
||||||
|
padding: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats,
|
||||||
|
.form-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-wide,
|
||||||
|
.field-full {
|
||||||
|
grid-column: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sync-status {
|
||||||
|
width: 100%;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% block head_extra %}{% endblock %}
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="page">
|
||||||
|
<nav class="nav">
|
||||||
|
<a href="/" class="{% if request.url.path == '/' %}active{% endif %}">대시보드</a>
|
||||||
|
<a href="/projects" class="{% if request.url.path == '/projects' %}active{% endif %}">사업현황</a>
|
||||||
|
<a href="/annual-summary" class="{% if request.url.path == '/annual-summary' %}active{% endif %}">연도별 수익 비용 정리</a>
|
||||||
|
<div class="nav-spacer"></div>
|
||||||
|
<aside
|
||||||
|
class="sync-status"
|
||||||
|
id="syncStatusWidget"
|
||||||
|
data-data-version="{{ data_version or '' }}"
|
||||||
|
data-refresh-url="{{ request.url.path }}{% if request.url.query %}?{{ request.url.query }}{% endif %}"
|
||||||
|
>
|
||||||
|
<div class="sync-status-head">
|
||||||
|
<div class="sync-status-title">
|
||||||
|
<span class="sync-dot" id="syncStatusDot"></span>
|
||||||
|
<span id="syncStatusLabel">연결 확인 중</span>
|
||||||
|
</div>
|
||||||
|
<span class="sync-pill" id="syncSessionPill">세션 준비 중</span>
|
||||||
|
</div>
|
||||||
|
<div class="sync-meta">
|
||||||
|
<div>마지막 확인: <strong id="syncLastChecked">-</strong></div>
|
||||||
|
<div>서버 시간: <strong id="syncServerTime">{{ server_time or '-' }}</strong></div>
|
||||||
|
<div>데이터 버전: <strong id="syncDataVersion">{{ data_version or '-' }}</strong></div>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
{% if message %}
|
||||||
|
<div class="message">{{ message }}</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
</div>
|
||||||
|
{% block script %}{% endblock %}
|
||||||
|
<script>
|
||||||
|
(() => {
|
||||||
|
const widget = document.getElementById("syncStatusWidget");
|
||||||
|
if (!widget) return;
|
||||||
|
|
||||||
|
const dot = document.getElementById("syncStatusDot");
|
||||||
|
const label = document.getElementById("syncStatusLabel");
|
||||||
|
const sessionPill = document.getElementById("syncSessionPill");
|
||||||
|
const lastChecked = document.getElementById("syncLastChecked");
|
||||||
|
const serverTime = document.getElementById("syncServerTime");
|
||||||
|
const dataVersion = document.getElementById("syncDataVersion");
|
||||||
|
let pageVersion = widget.dataset.dataVersion || "";
|
||||||
|
const refreshUrl = widget.dataset.refreshUrl || window.location.href;
|
||||||
|
let refreshInFlight = false;
|
||||||
|
let pendingVersion = "";
|
||||||
|
let isFormDirty = false;
|
||||||
|
|
||||||
|
function getSessionId() {
|
||||||
|
const key = "intranet-client-session-id";
|
||||||
|
let sessionId = window.localStorage.getItem(key);
|
||||||
|
if (!sessionId) {
|
||||||
|
sessionId = `session-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
|
||||||
|
window.localStorage.setItem(key, sessionId);
|
||||||
|
}
|
||||||
|
return sessionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
const clientSessionId = getSessionId();
|
||||||
|
sessionPill.textContent = clientSessionId;
|
||||||
|
|
||||||
|
function updateWidgetTitle() {
|
||||||
|
widget.title = [
|
||||||
|
`상태: ${label.textContent}`,
|
||||||
|
`세션: ${sessionPill.textContent}`,
|
||||||
|
`마지막 확인: ${lastChecked.textContent}`,
|
||||||
|
`서버 시간: ${serverTime.textContent}`,
|
||||||
|
`데이터 버전: ${dataVersion.textContent}`,
|
||||||
|
].join("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
function prepareCollabForms() {
|
||||||
|
document.querySelectorAll("form[data-collab-form]").forEach((form) => {
|
||||||
|
let sessionInput = form.querySelector('input[name="client_session_id"]');
|
||||||
|
if (!sessionInput) {
|
||||||
|
sessionInput = document.createElement("input");
|
||||||
|
sessionInput.type = "hidden";
|
||||||
|
sessionInput.name = "client_session_id";
|
||||||
|
form.appendChild(sessionInput);
|
||||||
|
}
|
||||||
|
sessionInput.value = clientSessionId;
|
||||||
|
|
||||||
|
let submittedInput = form.querySelector('input[name="client_submitted_at"]');
|
||||||
|
if (!submittedInput) {
|
||||||
|
submittedInput = document.createElement("input");
|
||||||
|
submittedInput.type = "hidden";
|
||||||
|
submittedInput.name = "client_submitted_at";
|
||||||
|
form.appendChild(submittedInput);
|
||||||
|
}
|
||||||
|
|
||||||
|
const markDirty = () => {
|
||||||
|
isFormDirty = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
form.addEventListener("input", markDirty);
|
||||||
|
form.addEventListener("change", markDirty);
|
||||||
|
form.addEventListener("submit", () => {
|
||||||
|
isFormDirty = false;
|
||||||
|
submittedInput.value = new Date().toISOString();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
prepareCollabForms();
|
||||||
|
|
||||||
|
function setStatus(kind, text) {
|
||||||
|
dot.classList.remove("online", "error");
|
||||||
|
if (kind === "online") dot.classList.add("online");
|
||||||
|
if (kind === "error") dot.classList.add("error");
|
||||||
|
label.textContent = text;
|
||||||
|
lastChecked.textContent = new Date().toLocaleTimeString("ko-KR", { hour12: false });
|
||||||
|
updateWidgetTitle();
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasActiveEditor() {
|
||||||
|
const active = document.activeElement;
|
||||||
|
return Boolean(active && active.closest && active.closest("form[data-collab-form]"));
|
||||||
|
}
|
||||||
|
|
||||||
|
function shouldDelayRefresh() {
|
||||||
|
return isFormDirty || hasActiveEditor();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refreshPageWhenSafe(nextVersion) {
|
||||||
|
if (refreshInFlight) return;
|
||||||
|
if (shouldDelayRefresh()) {
|
||||||
|
pendingVersion = nextVersion || pendingVersion || pageVersion;
|
||||||
|
setStatus("online", "새 데이터 대기 중");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
refreshInFlight = true;
|
||||||
|
pendingVersion = nextVersion || pendingVersion || "";
|
||||||
|
setStatus("online", "새 데이터 반영 중");
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(refreshUrl, {
|
||||||
|
cache: "no-store",
|
||||||
|
credentials: "same-origin",
|
||||||
|
headers: { "X-Requested-With": "XMLHttpRequest" },
|
||||||
|
});
|
||||||
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||||
|
const html = await response.text();
|
||||||
|
document.open();
|
||||||
|
document.write(html);
|
||||||
|
document.close();
|
||||||
|
} catch (error) {
|
||||||
|
refreshInFlight = false;
|
||||||
|
setStatus("error", "업데이트 재시도 중");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function pollHealth() {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`/health?ts=${Date.now()}`, { cache: "no-store" });
|
||||||
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||||
|
const payload = await response.json();
|
||||||
|
serverTime.textContent = payload.server_time || "-";
|
||||||
|
dataVersion.textContent = payload.data_version || "-";
|
||||||
|
updateWidgetTitle();
|
||||||
|
if (payload.data_version && payload.data_version !== pageVersion) {
|
||||||
|
pendingVersion = payload.data_version;
|
||||||
|
await refreshPageWhenSafe(payload.data_version);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (pendingVersion && pendingVersion !== pageVersion) {
|
||||||
|
await refreshPageWhenSafe(pendingVersion);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setStatus("online", "서버 정상 연결");
|
||||||
|
} catch (error) {
|
||||||
|
setStatus("error", "연결 오류");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pollHealth();
|
||||||
|
updateWidgetTitle();
|
||||||
|
document.addEventListener("visibilitychange", () => {
|
||||||
|
if (!document.hidden) {
|
||||||
|
pollHealth();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
window.setInterval(pollHealth, 15000);
|
||||||
|
})();
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,618 @@
|
|||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block title %}대시보드{% endblock %}
|
||||||
|
|
||||||
|
{% block head_extra %}
|
||||||
|
<style>
|
||||||
|
.hero {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 18px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-copy {
|
||||||
|
display: grid;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.hero-copy p {
|
||||||
|
color: var(--muted);
|
||||||
|
max-width: 920px;
|
||||||
|
line-height: 1.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-actions {
|
||||||
|
position: relative;
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-actions:hover .upload-tooltip,
|
||||||
|
.upload-actions:focus-within .upload-tooltip {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
pointer-events: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-tooltip {
|
||||||
|
position: absolute;
|
||||||
|
top: calc(100% + 12px);
|
||||||
|
right: 0;
|
||||||
|
width: 280px;
|
||||||
|
background: rgba(20, 20, 20, 0.96);
|
||||||
|
color: #f8fbfd;
|
||||||
|
border-radius: 14px;
|
||||||
|
padding: 14px 16px;
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.7;
|
||||||
|
box-shadow: 0 18px 35px rgba(20, 20, 20, 0.18);
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(-6px);
|
||||||
|
pointer-events: none;
|
||||||
|
transition: opacity 0.18s ease, transform 0.18s ease;
|
||||||
|
z-index: 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-tooltip::before {
|
||||||
|
content: "";
|
||||||
|
position: absolute;
|
||||||
|
top: -8px;
|
||||||
|
right: 22px;
|
||||||
|
border-left: 8px solid transparent;
|
||||||
|
border-right: 8px solid transparent;
|
||||||
|
border-bottom: 8px solid rgba(20, 20, 20, 0.96);
|
||||||
|
}
|
||||||
|
|
||||||
|
.hidden-file-input {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, minmax(150px, 1fr));
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-panel {
|
||||||
|
display: grid;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.filter-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, minmax(0, 220px)) auto;
|
||||||
|
gap: 12px;
|
||||||
|
align-items: end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-shell {
|
||||||
|
background:
|
||||||
|
linear-gradient(180deg, rgba(255,255,255,0.98), rgba(246,247,249,0.98)),
|
||||||
|
radial-gradient(circle at top left, rgba(24, 24, 27, 0.045), transparent 38%);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 16px;
|
||||||
|
box-shadow: inset 0 1px 0 rgba(255,255,255,0.92);
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-head {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 14px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-head p {
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 14px;
|
||||||
|
line-height: 1.7;
|
||||||
|
}
|
||||||
|
|
||||||
|
.legend-box {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 10px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.legend-item {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
border-radius: 10px;
|
||||||
|
padding: 6px 10px;
|
||||||
|
background: rgba(255,255,255,0.92);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
color: #363b44;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric-grid .stat-card {
|
||||||
|
min-height: 118px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.metric-grid .stat-card .value {
|
||||||
|
margin-top: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.legend-swatch {
|
||||||
|
width: 10px;
|
||||||
|
height: 10px;
|
||||||
|
border-radius: 999px;
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-svg {
|
||||||
|
width: 100%;
|
||||||
|
height: auto;
|
||||||
|
aspect-ratio: 1120 / 390;
|
||||||
|
min-height: 320px;
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1200px) {
|
||||||
|
.metric-grid,
|
||||||
|
.filter-row {
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 780px) {
|
||||||
|
.metric-grid,
|
||||||
|
.filter-row {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<section class="panel">
|
||||||
|
<div class="hero">
|
||||||
|
<div class="hero-copy">
|
||||||
|
<div class="section-title" style="margin-bottom: 0;">
|
||||||
|
<h2>대시보드</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="upload-actions">
|
||||||
|
<form action="/upload" method="post" enctype="multipart/form-data" id="uploadForm">
|
||||||
|
<input id="excel_file" class="hidden-file-input" type="file" name="excel_file" accept=".xlsx,.xlsm,.xltx,.xltm" required>
|
||||||
|
<button type="button" id="uploadButton" class="button-icon" title="업로드 저장" aria-label="업로드 저장">
|
||||||
|
<svg viewBox="0 0 24 24" aria-hidden="true">
|
||||||
|
<path d="M6 4h9l3 3v13H6z"></path>
|
||||||
|
<path d="M9 4v6h6V4"></path>
|
||||||
|
<path d="M9 17h6"></path>
|
||||||
|
</svg>
|
||||||
|
<span class="sr-only">업로드 저장</span>
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
<div class="upload-tooltip">엑셀 파일을 선택하면 회계 데이터를 DB에 바로 저장합니다. 프로젝트 폴더에 둔 파일 외에 추가 파일을 수동 반영할 때 사용하세요.</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="panel">
|
||||||
|
<div class="section-title">
|
||||||
|
<h2>현황 요약</h2>
|
||||||
|
</div>
|
||||||
|
<form method="get" action="/" class="filter-row" style="margin-bottom: 16px;">
|
||||||
|
<div class="field">
|
||||||
|
<select id="overviewYear" name="overview_year" aria-label="연도 선택">
|
||||||
|
<option value="" {% if not overview_selected_year %}selected{% endif %}>최근 10개년</option>
|
||||||
|
{% for year in available_years %}
|
||||||
|
<option value="{{ year }}" {% if overview_selected_year == year %}selected{% endif %}>{{ year }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
<div class="metric-grid">
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="label">집계 대상 사업 수</div>
|
||||||
|
<div class="value">{{ overview.business_count or 0 }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="label">수입금액</div>
|
||||||
|
<div class="value">{{ "{:,.0f}".format(overview.total_revenue or 0) }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="label">원가 총액</div>
|
||||||
|
<div class="value">{{ "{:,.0f}".format(overview.total_cost or 0) }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="label">판관비 총액</div>
|
||||||
|
<div class="value">{{ "{:,.0f}".format(overview.total_sga or 0) }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="panel chart-panel">
|
||||||
|
<div class="section-title">
|
||||||
|
<h2>통합 비용 집계</h2>
|
||||||
|
</div>
|
||||||
|
<div class="filter-row">
|
||||||
|
<div class="field">
|
||||||
|
<select id="summaryGranularity" aria-label="집계 단위">
|
||||||
|
<option value="yearly">연도별</option>
|
||||||
|
<option value="monthly">월별</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<select id="summaryYear" aria-label="연도 선택">
|
||||||
|
<option value="all">전체연도</option>
|
||||||
|
{% for year in available_years %}
|
||||||
|
<option value="{{ year }}">{{ year }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<select id="summaryMetric" aria-label="강조 항목">
|
||||||
|
<option value="all">전체 항목</option>
|
||||||
|
<option value="cost_sum">원가</option>
|
||||||
|
<option value="sga_sum">판관비</option>
|
||||||
|
<option value="labor_sum">원가인건비</option>
|
||||||
|
<option value="outsourcing_sum">원가외주비</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="legend-box" id="summaryLegend"></div>
|
||||||
|
</div>
|
||||||
|
<div class="chart-shell">
|
||||||
|
<svg id="summaryChart" class="chart-svg" viewBox="0 0 1120 390" preserveAspectRatio="xMidYMid meet"></svg>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="panel chart-panel">
|
||||||
|
<div class="section-title">
|
||||||
|
<h2>원가·판관비 추세</h2>
|
||||||
|
</div>
|
||||||
|
<div class="filter-row">
|
||||||
|
<div class="field">
|
||||||
|
<select id="trendYear" aria-label="연도 선택">
|
||||||
|
<option value="recent10">최근 10개년</option>
|
||||||
|
{% for year in available_years %}
|
||||||
|
<option value="{{ year }}">{{ year }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<select id="trendMetric" aria-label="표시 방식">
|
||||||
|
<option value="cost_sga">원가 + 판관비</option>
|
||||||
|
<option value="all">전체 항목</option>
|
||||||
|
<option value="labor_outsourcing">인건비 + 외주비</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div></div>
|
||||||
|
<div class="legend-box" id="trendLegend"></div>
|
||||||
|
</div>
|
||||||
|
<div class="chart-shell">
|
||||||
|
<svg id="trendChart" class="chart-svg" viewBox="0 0 1120 390" preserveAspectRatio="xMidYMid meet"></svg>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block script %}
|
||||||
|
<script>
|
||||||
|
const yearlySummary = {{ yearly_summary | tojson }};
|
||||||
|
const monthlySummary = {{ monthly_summary | tojson }};
|
||||||
|
const availableYears = {{ available_years | tojson }};
|
||||||
|
|
||||||
|
const palette = {
|
||||||
|
cost_sum: { label: "원가", color: "#4f7cff" },
|
||||||
|
sga_sum: { label: "판관비", color: "#67c7c9" },
|
||||||
|
labor_sum: { label: "원가인건비", color: "#233a5a" },
|
||||||
|
outsourcing_sum: { label: "원가외주비", color: "#ffb54a" },
|
||||||
|
};
|
||||||
|
|
||||||
|
const summaryMetricsMap = {
|
||||||
|
all: ["cost_sum", "sga_sum", "labor_sum", "outsourcing_sum"],
|
||||||
|
cost_sum: ["cost_sum"],
|
||||||
|
sga_sum: ["sga_sum"],
|
||||||
|
labor_sum: ["labor_sum"],
|
||||||
|
outsourcing_sum: ["outsourcing_sum"],
|
||||||
|
};
|
||||||
|
|
||||||
|
const trendMetricsMap = {
|
||||||
|
cost_sga: ["cost_sum", "sga_sum"],
|
||||||
|
all: ["cost_sum", "sga_sum", "labor_sum", "outsourcing_sum"],
|
||||||
|
labor_outsourcing: ["labor_sum", "outsourcing_sum"],
|
||||||
|
};
|
||||||
|
|
||||||
|
function formatNumber(value) {
|
||||||
|
return new Intl.NumberFormat("ko-KR", { maximumFractionDigits: 0 }).format(value || 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatValueLabel(value) {
|
||||||
|
const numeric = Number(value || 0);
|
||||||
|
if (!numeric) return "0.0";
|
||||||
|
if (numeric >= 100000000) return `${(numeric / 100000000).toFixed(1)}억`;
|
||||||
|
if (numeric >= 1000000) return `${(numeric / 1000000).toFixed(1)}백만`;
|
||||||
|
if (numeric >= 1000) return `${(numeric / 1000).toFixed(1)}천`;
|
||||||
|
return numeric.toFixed(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatAxisLabel(value) {
|
||||||
|
const numeric = Number(value || 0);
|
||||||
|
if (!numeric) return "0";
|
||||||
|
if (numeric >= 100000000) return `${numeric / 100000000}억`;
|
||||||
|
if (numeric >= 1000000) return `${numeric / 1000000}백만`;
|
||||||
|
if (numeric >= 1000) return `${numeric / 1000}천`;
|
||||||
|
return formatNumber(numeric);
|
||||||
|
}
|
||||||
|
|
||||||
|
function pickTickStep(maxValue) {
|
||||||
|
const baseUnit = maxValue < 1000000 ? 1000 : 1000000;
|
||||||
|
const units = [1, 2, 5];
|
||||||
|
const raw = Math.max(maxValue / 5 / baseUnit, 1);
|
||||||
|
let power = 1;
|
||||||
|
while (power * 10 <= raw) power *= 10;
|
||||||
|
for (const unit of units) {
|
||||||
|
const candidate = unit * power;
|
||||||
|
if (candidate >= raw) return candidate * baseUnit;
|
||||||
|
}
|
||||||
|
return power * 10 * baseUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setLegend(containerId, metricKeys) {
|
||||||
|
const target = document.getElementById(containerId);
|
||||||
|
if (!target) return;
|
||||||
|
target.innerHTML = metricKeys.map((key) => `
|
||||||
|
<span class="legend-item">
|
||||||
|
<span class="legend-swatch" style="background:${palette[key].color}"></span>
|
||||||
|
${palette[key].label}
|
||||||
|
</span>
|
||||||
|
`).join("");
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderEmptyChart(svgId, message) {
|
||||||
|
const svg = document.getElementById(svgId);
|
||||||
|
if (!svg) return;
|
||||||
|
svg.innerHTML = `
|
||||||
|
<rect x="0" y="0" width="1120" height="390" rx="8" fill="#f7fafb" stroke="#d6e2e8"></rect>
|
||||||
|
<text x="560" y="195" text-anchor="middle" fill="#667887" font-size="18" font-weight="700">${message}</text>
|
||||||
|
`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderGroupedBarChart(svgId, rows, metricKeys, options = {}) {
|
||||||
|
const svg = document.getElementById(svgId);
|
||||||
|
if (!svg) return;
|
||||||
|
if (!rows.length || !metricKeys.length) {
|
||||||
|
renderEmptyChart(svgId, "표시할 집계 데이터가 없습니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const granularity = options.granularity || "yearly";
|
||||||
|
const width = 1120;
|
||||||
|
const height = 390;
|
||||||
|
const margin = { top: 42, right: 36, bottom: 78, left: 94 };
|
||||||
|
const plotWidth = width - margin.left - margin.right;
|
||||||
|
const plotHeight = height - margin.top - margin.bottom;
|
||||||
|
const maxValue = Math.max(
|
||||||
|
1,
|
||||||
|
...rows.flatMap((row) => metricKeys.map((key) => Number(row[key] || 0))),
|
||||||
|
);
|
||||||
|
const tickStep = pickTickStep(maxValue);
|
||||||
|
const tickMax = Math.ceil(maxValue / tickStep) * tickStep;
|
||||||
|
const groupWidth = plotWidth / Math.max(rows.length, 1);
|
||||||
|
const axisBaseY = height - margin.bottom;
|
||||||
|
const groupGapRatio = granularity === "monthly" ? 0.28 : 0.18;
|
||||||
|
const innerGap = granularity === "monthly" ? 7 : 10;
|
||||||
|
const groupInset = Math.max(groupWidth * groupGapRatio, granularity === "monthly" ? 8 : 12);
|
||||||
|
const usableGroupWidth = Math.max(groupWidth - groupInset * 2, metricKeys.length * 12);
|
||||||
|
const barWidth = Math.min((usableGroupWidth - innerGap * Math.max(metricKeys.length - 1, 0)) / Math.max(metricKeys.length, 1), granularity === "monthly" ? 18 : 34);
|
||||||
|
const actualGroupWidth = barWidth * metricKeys.length + innerGap * Math.max(metricKeys.length - 1, 0);
|
||||||
|
const groupStartOffset = (groupWidth - actualGroupWidth) / 2;
|
||||||
|
const xLabelStep = granularity === "monthly" ? 1 : Math.max(1, Math.ceil(rows.length / 10));
|
||||||
|
|
||||||
|
let markup = `
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="${svgId}Bg" x1="0" x2="1" y1="0" y2="1">
|
||||||
|
<stop offset="0%" stop-color="#fcfefe" />
|
||||||
|
<stop offset="100%" stop-color="#edf4f7" />
|
||||||
|
</linearGradient>
|
||||||
|
<filter id="${svgId}Shadow" x="-20%" y="-20%" width="140%" height="160%">
|
||||||
|
<feDropShadow dx="0" dy="8" stdDeviation="8" flood-color="rgba(44, 68, 89, 0.14)" />
|
||||||
|
</filter>
|
||||||
|
</defs>
|
||||||
|
<rect x="0" y="0" width="${width}" height="${height}" rx="8" fill="url(#${svgId}Bg)"></rect>
|
||||||
|
<rect x="${margin.left}" y="${margin.top}" width="${plotWidth}" height="${plotHeight}" rx="4" fill="rgba(255,255,255,0.72)" stroke="#dde7ec"></rect>
|
||||||
|
<text x="${margin.left}" y="24" fill="#334654" font-size="14" font-weight="700">${granularity === "monthly" ? "월간 비교" : "연간 비교"}</text>
|
||||||
|
`;
|
||||||
|
|
||||||
|
for (let value = 0; value <= tickMax; value += tickStep) {
|
||||||
|
const y = margin.top + plotHeight - (value / tickMax) * plotHeight;
|
||||||
|
markup += `<line x1="${margin.left}" y1="${y}" x2="${width - margin.right}" y2="${y}" stroke="#d8e3e8" stroke-dasharray="3 7"></line>`;
|
||||||
|
markup += `<text x="${margin.left - 16}" y="${y + 4}" text-anchor="end" fill="#60717d" font-size="11.5" font-weight="700">${formatAxisLabel(value)}</text>`;
|
||||||
|
}
|
||||||
|
markup += `<line x1="${margin.left}" y1="${axisBaseY}" x2="${width - margin.right}" y2="${axisBaseY}" stroke="#8ea0ac" stroke-width="1.2"></line>`;
|
||||||
|
|
||||||
|
rows.forEach((row, rowIndex) => {
|
||||||
|
const baseX = margin.left + rowIndex * groupWidth;
|
||||||
|
const showXAxisLabel = rows.length <= 14 || rowIndex % xLabelStep === 0 || rowIndex === rows.length - 1;
|
||||||
|
metricKeys.forEach((key, metricIndex) => {
|
||||||
|
const value = Number(row[key] || 0);
|
||||||
|
const x = baseX + groupStartOffset + metricIndex * (barWidth + innerGap);
|
||||||
|
const drawWidth = Math.max(barWidth, 10);
|
||||||
|
const barHeight = tickMax ? (value / tickMax) * plotHeight : 0;
|
||||||
|
const y = margin.top + plotHeight - barHeight;
|
||||||
|
const labelY = Math.max(y - 12, margin.top - 8);
|
||||||
|
const showValueLabel = barHeight > 24 && (granularity === "yearly" || metricKeys.length <= 2 || drawWidth >= 16);
|
||||||
|
markup += `<rect x="${x}" y="${y}" width="${drawWidth}" height="${barHeight}" rx="3" fill="${palette[key].color}" filter="url(#${svgId}Shadow)"></rect>`;
|
||||||
|
if (showValueLabel) {
|
||||||
|
markup += `<text x="${x + drawWidth / 2}" y="${labelY}" text-anchor="middle" fill="#35505f" font-size="10" font-weight="700">${formatValueLabel(value)}</text>`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (showXAxisLabel) {
|
||||||
|
markup += `<text x="${baseX + groupWidth / 2}" y="${height - 28}" text-anchor="middle" fill="#405362" font-size="12.5" font-weight="700">${row.label}</text>`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
svg.innerHTML = markup;
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderLineChart(svgId, rows, metricKeys) {
|
||||||
|
const svg = document.getElementById(svgId);
|
||||||
|
if (!svg) return;
|
||||||
|
const width = 1120;
|
||||||
|
const height = 390;
|
||||||
|
const margin = { top: 24, right: 24, bottom: 64, left: 86 };
|
||||||
|
const plotWidth = width - margin.left - margin.right;
|
||||||
|
const plotHeight = height - margin.top - margin.bottom;
|
||||||
|
const maxValue = Math.max(
|
||||||
|
1,
|
||||||
|
...rows.flatMap((row) => metricKeys.map((key) => Number(row[key] || 0))),
|
||||||
|
);
|
||||||
|
const tickStep = pickTickStep(maxValue);
|
||||||
|
const tickMax = Math.ceil(maxValue / tickStep) * tickStep;
|
||||||
|
const xStep = rows.length > 1 ? plotWidth / (rows.length - 1) : 0;
|
||||||
|
const axisBaseY = height - margin.bottom;
|
||||||
|
|
||||||
|
let markup = `
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="${svgId}Bg" x1="0" x2="0" y1="0" y2="1">
|
||||||
|
<stop offset="0%" stop-color="#ffffff" stop-opacity="0.9" />
|
||||||
|
<stop offset="100%" stop-color="#f3f8fa" stop-opacity="0.98" />
|
||||||
|
</linearGradient>
|
||||||
|
<filter id="${svgId}Shadow" x="-20%" y="-20%" width="140%" height="160%">
|
||||||
|
<feDropShadow dx="0" dy="8" stdDeviation="8" flood-color="rgba(44, 68, 89, 0.16)" />
|
||||||
|
</filter>
|
||||||
|
</defs>
|
||||||
|
<rect x="0" y="0" width="${width}" height="${height}" rx="24" fill="url(#${svgId}Bg)"></rect>
|
||||||
|
<rect x="${margin.left}" y="${margin.top}" width="${plotWidth}" height="${plotHeight}" rx="18" fill="rgba(255,255,255,0.68)"></rect>
|
||||||
|
`;
|
||||||
|
|
||||||
|
for (let value = 0; value <= tickMax; value += tickStep) {
|
||||||
|
const y = margin.top + plotHeight - (value / tickMax) * plotHeight;
|
||||||
|
markup += `<line x1="${margin.left}" y1="${y}" x2="${width - margin.right}" y2="${y}" stroke="#d6e2e8" stroke-dasharray="4 7"></line>`;
|
||||||
|
markup += `<text x="${margin.left - 14}" y="${y + 5}" text-anchor="end" fill="#62717f" font-size="12">${formatAxisLabel(value)}</text>`;
|
||||||
|
}
|
||||||
|
markup += `<line x1="${margin.left}" y1="${axisBaseY}" x2="${width - margin.right}" y2="${axisBaseY}" stroke="#7f95a5" stroke-width="1.2"></line>`;
|
||||||
|
|
||||||
|
metricKeys.forEach((key) => {
|
||||||
|
const points = rows.map((row, index) => {
|
||||||
|
const x = margin.left + index * xStep;
|
||||||
|
const y = margin.top + plotHeight - ((Number(row[key] || 0) / tickMax) * plotHeight);
|
||||||
|
return { x, y, value: Number(row[key] || 0), label: row.label };
|
||||||
|
});
|
||||||
|
markup += `<path d="M ${points.map((p) => `${p.x} ${p.y}`).join(" L ")}" fill="none" stroke="${palette[key].color}" stroke-width="4" stroke-linecap="round" stroke-linejoin="round" filter="url(#${svgId}Shadow)"></path>`;
|
||||||
|
points.forEach((point) => {
|
||||||
|
markup += `<circle cx="${point.x}" cy="${point.y}" r="5.5" fill="${palette[key].color}" stroke="#ffffff" stroke-width="2"></circle>`;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
rows.forEach((row, index) => {
|
||||||
|
const x = margin.left + index * xStep;
|
||||||
|
if (rows.length <= 18 || index % Math.ceil(rows.length / 12) === 0) {
|
||||||
|
markup += `<text x="${x}" y="${height - 26}" text-anchor="middle" fill="#425464" font-size="13" font-weight="700">${row.label}</text>`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
svg.innerHTML = markup;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSummaryRows() {
|
||||||
|
const granularity = document.getElementById("summaryGranularity").value;
|
||||||
|
const yearFilter = document.getElementById("summaryYear").value;
|
||||||
|
const source = granularity === "yearly" ? yearlySummary : monthlySummary;
|
||||||
|
return source
|
||||||
|
.filter((row) => {
|
||||||
|
if (granularity === "yearly") return true;
|
||||||
|
return yearFilter === "all" ? true : String(row.year) === yearFilter;
|
||||||
|
})
|
||||||
|
.map((row) => ({
|
||||||
|
...row,
|
||||||
|
label: granularity === "yearly" ? String(row.year) : `${row.month}월`,
|
||||||
|
}))
|
||||||
|
.slice(granularity === "yearly" ? -10 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getLatestAvailableYear() {
|
||||||
|
return String(availableYears[availableYears.length - 1] || "all");
|
||||||
|
}
|
||||||
|
|
||||||
|
function syncSummaryYearSelection(granularity) {
|
||||||
|
const summaryYearSelect = document.getElementById("summaryYear");
|
||||||
|
if (!summaryYearSelect) return;
|
||||||
|
|
||||||
|
if (granularity === "yearly") {
|
||||||
|
summaryYearSelect.value = "all";
|
||||||
|
summaryYearSelect.disabled = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasSelectedYear = availableYears.some((year) => String(year) === String(summaryYearSelect.value));
|
||||||
|
if (summaryYearSelect.value === "all" || !hasSelectedYear) {
|
||||||
|
summaryYearSelect.value = getLatestAvailableYear();
|
||||||
|
}
|
||||||
|
summaryYearSelect.disabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateSummaryChart() {
|
||||||
|
const granularity = document.getElementById("summaryGranularity").value;
|
||||||
|
const metricMode = document.getElementById("summaryMetric").value;
|
||||||
|
const metricKeys = summaryMetricsMap[metricMode];
|
||||||
|
syncSummaryYearSelection(granularity);
|
||||||
|
const rows = getSummaryRows();
|
||||||
|
setLegend("summaryLegend", metricKeys);
|
||||||
|
renderGroupedBarChart("summaryChart", rows, metricKeys, { granularity });
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateTrendChart() {
|
||||||
|
const selectedYear = document.getElementById("trendYear").value;
|
||||||
|
const metricMode = document.getElementById("trendMetric").value;
|
||||||
|
const metricKeys = trendMetricsMap[metricMode];
|
||||||
|
const rows = selectedYear === "recent10"
|
||||||
|
? yearlySummary
|
||||||
|
.slice(-10)
|
||||||
|
.map((row) => ({
|
||||||
|
...row,
|
||||||
|
label: String(row.year),
|
||||||
|
}))
|
||||||
|
: monthlySummary
|
||||||
|
.filter((row) => String(row.year) === String(selectedYear))
|
||||||
|
.map((row) => ({ ...row, label: `${row.month}월` }));
|
||||||
|
setLegend("trendLegend", metricKeys);
|
||||||
|
renderLineChart("trendChart", rows, metricKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById("summaryGranularity")?.addEventListener("change", updateSummaryChart);
|
||||||
|
document.getElementById("summaryYear")?.addEventListener("change", updateSummaryChart);
|
||||||
|
document.getElementById("summaryMetric")?.addEventListener("change", updateSummaryChart);
|
||||||
|
document.getElementById("trendYear")?.addEventListener("change", updateTrendChart);
|
||||||
|
document.getElementById("trendMetric")?.addEventListener("change", updateTrendChart);
|
||||||
|
|
||||||
|
const defaultYear = getLatestAvailableYear();
|
||||||
|
const trendYear = document.getElementById("trendYear");
|
||||||
|
if (trendYear) {
|
||||||
|
trendYear.value = "recent10";
|
||||||
|
}
|
||||||
|
const summaryYear = document.getElementById("summaryYear");
|
||||||
|
if (summaryYear) {
|
||||||
|
syncSummaryYearSelection(document.getElementById("summaryGranularity")?.value || "yearly");
|
||||||
|
}
|
||||||
|
|
||||||
|
const uploadButton = document.getElementById("uploadButton");
|
||||||
|
const excelInput = document.getElementById("excel_file");
|
||||||
|
const uploadForm = document.getElementById("uploadForm");
|
||||||
|
const overviewYear = document.getElementById("overviewYear");
|
||||||
|
|
||||||
|
overviewYear?.addEventListener("change", (event) => {
|
||||||
|
event.target.form?.submit();
|
||||||
|
});
|
||||||
|
|
||||||
|
uploadButton?.addEventListener("click", () => {
|
||||||
|
excelInput?.click();
|
||||||
|
});
|
||||||
|
|
||||||
|
excelInput?.addEventListener("change", () => {
|
||||||
|
if (excelInput.files && excelInput.files.length > 0) {
|
||||||
|
uploadForm.submit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
updateSummaryChart();
|
||||||
|
updateTrendChart();
|
||||||
|
</script>
|
||||||
|
{% endblock %}
|
||||||
@@ -0,0 +1,591 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ko">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>회계 데이터 인트라넷 대시보드</title>
|
||||||
|
<style>
|
||||||
|
:root {
|
||||||
|
--bg-a: #f3efe7;
|
||||||
|
--bg-b: #d7e5eb;
|
||||||
|
--panel: rgba(255, 252, 247, 0.92);
|
||||||
|
--ink: #14212f;
|
||||||
|
--muted: #5a6672;
|
||||||
|
--line: #d8dee5;
|
||||||
|
--accent: #0b6b63;
|
||||||
|
--accent-strong: #074b49;
|
||||||
|
--accent-soft: #e6f5f2;
|
||||||
|
--warn: #fff0c9;
|
||||||
|
--table-alt: #f9fbfc;
|
||||||
|
--white: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: "Noto Sans KR", "Malgun Gothic", sans-serif;
|
||||||
|
color: var(--ink);
|
||||||
|
background:
|
||||||
|
radial-gradient(circle at top left, rgba(255, 255, 255, 0.9), transparent 28%),
|
||||||
|
linear-gradient(155deg, var(--bg-a), var(--bg-b));
|
||||||
|
min-height: 100vh;
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page {
|
||||||
|
max-width: 1480px;
|
||||||
|
margin: 0 auto;
|
||||||
|
display: grid;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel {
|
||||||
|
background: var(--panel);
|
||||||
|
border: 1px solid rgba(255, 255, 255, 0.6);
|
||||||
|
border-radius: 24px;
|
||||||
|
padding: 24px;
|
||||||
|
box-shadow: 0 20px 45px rgba(51, 76, 92, 0.12);
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title h2 {
|
||||||
|
font-size: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section-title p {
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message {
|
||||||
|
background: var(--warn);
|
||||||
|
border: 1px solid #efd486;
|
||||||
|
color: #624c0b;
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 14px 16px;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(5, minmax(0, 1fr));
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 18px;
|
||||||
|
margin-top: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card {
|
||||||
|
background: var(--white);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 18px;
|
||||||
|
padding: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card .label {
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 13px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stat-card .value {
|
||||||
|
font-size: 28px;
|
||||||
|
font-weight: 800;
|
||||||
|
line-height: 1.1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.two-col {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 0.92fr 1.08fr;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stack {
|
||||||
|
display: grid;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
form {
|
||||||
|
display: grid;
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-box {
|
||||||
|
background: linear-gradient(180deg, #f8fffd, #eef8f6);
|
||||||
|
border: 1px dashed #a7d1c8;
|
||||||
|
border-radius: 18px;
|
||||||
|
padding: 18px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.upload-box p {
|
||||||
|
color: var(--muted);
|
||||||
|
line-height: 1.65;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||||
|
gap: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field {
|
||||||
|
display: grid;
|
||||||
|
gap: 7px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-wide {
|
||||||
|
grid-column: span 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-full {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
font-size: 13px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--muted);
|
||||||
|
}
|
||||||
|
|
||||||
|
input,
|
||||||
|
select,
|
||||||
|
textarea,
|
||||||
|
button {
|
||||||
|
font: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="text"],
|
||||||
|
input[type="number"],
|
||||||
|
input[type="date"],
|
||||||
|
input[type="file"],
|
||||||
|
textarea {
|
||||||
|
width: 100%;
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
background: var(--white);
|
||||||
|
border-radius: 14px;
|
||||||
|
padding: 12px 14px;
|
||||||
|
color: var(--ink);
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
min-height: 96px;
|
||||||
|
resize: vertical;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:focus,
|
||||||
|
textarea:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: var(--accent);
|
||||||
|
box-shadow: 0 0 0 4px rgba(11, 107, 99, 0.12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 10px;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
button,
|
||||||
|
.button-link {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
border-radius: 999px;
|
||||||
|
border: none;
|
||||||
|
padding: 12px 18px;
|
||||||
|
background: var(--accent);
|
||||||
|
color: var(--white);
|
||||||
|
font-weight: 700;
|
||||||
|
cursor: pointer;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
button:hover,
|
||||||
|
.button-link:hover {
|
||||||
|
background: var(--accent-strong);
|
||||||
|
}
|
||||||
|
|
||||||
|
.button-secondary {
|
||||||
|
background: #e7f0f5;
|
||||||
|
color: #204257;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-wrap {
|
||||||
|
overflow: auto;
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: 18px;
|
||||||
|
background: var(--white);
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
border-collapse: collapse;
|
||||||
|
min-width: 780px;
|
||||||
|
}
|
||||||
|
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
padding: 12px 14px;
|
||||||
|
border-bottom: 1px solid var(--line);
|
||||||
|
text-align: left;
|
||||||
|
vertical-align: top;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
background: #eff5f7;
|
||||||
|
color: #345061;
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
tbody tr:nth-child(even) td {
|
||||||
|
background: var(--table-alt);
|
||||||
|
}
|
||||||
|
|
||||||
|
.empty {
|
||||||
|
padding: 24px;
|
||||||
|
color: var(--muted);
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.note-list {
|
||||||
|
display: grid;
|
||||||
|
gap: 8px;
|
||||||
|
color: var(--muted);
|
||||||
|
line-height: 1.7;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
details.panel summary {
|
||||||
|
list-style: none;
|
||||||
|
cursor: pointer;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 16px;
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
details.panel summary::-webkit-details-marker {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-box {
|
||||||
|
margin: 16px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mono {
|
||||||
|
font-family: "Consolas", "Courier New", monospace;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1200px) {
|
||||||
|
.stats {
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.two-col {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-grid {
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 720px) {
|
||||||
|
body {
|
||||||
|
padding: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.stats,
|
||||||
|
.form-grid {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-wide,
|
||||||
|
.field-full {
|
||||||
|
grid-column: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="page">
|
||||||
|
{% if message %}
|
||||||
|
<div class="message">{{ message }}</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<section class="panel">
|
||||||
|
<div class="section-title">
|
||||||
|
<h2>현황 요약</h2>
|
||||||
|
<p>DB에 저장된 전체 자료 기준</p>
|
||||||
|
</div>
|
||||||
|
<div class="stats">
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="label">전체 데이터 건수</div>
|
||||||
|
<div class="value">{{ overview.total_rows or 0 }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="label">업로드 파일 수</div>
|
||||||
|
<div class="value">{{ overview.source_files or 0 }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="label">집계 대상 사업 수</div>
|
||||||
|
<div class="value">{{ overview.business_count or 0 }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="label">원가 총액</div>
|
||||||
|
<div class="value">{{ "{:,.0f}".format(overview.total_cost or 0) }}</div>
|
||||||
|
</div>
|
||||||
|
<div class="stat-card">
|
||||||
|
<div class="label">판관비 총액</div>
|
||||||
|
<div class="value">{{ "{:,.0f}".format(overview.total_sga or 0) }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="summary-grid">
|
||||||
|
<div class="table-wrap">
|
||||||
|
{% if yearly_summary %}
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>연도</th>
|
||||||
|
<th>원가 합계</th>
|
||||||
|
<th>판관비 합계</th>
|
||||||
|
<th>원가인건비</th>
|
||||||
|
<th>원가외주비</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in yearly_summary %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ item.year }}</td>
|
||||||
|
<td>{{ "{:,.0f}".format(item.cost_sum or 0) }}</td>
|
||||||
|
<td>{{ "{:,.0f}".format(item.sga_sum or 0) }}</td>
|
||||||
|
<td>{{ "{:,.0f}".format(item.labor_sum or 0) }}</td>
|
||||||
|
<td>{{ "{:,.0f}".format(item.outsourcing_sum or 0) }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% else %}
|
||||||
|
<div class="empty">연간 집계 데이터가 없습니다.</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="table-wrap">
|
||||||
|
{% if monthly_summary %}
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>연도</th>
|
||||||
|
<th>월</th>
|
||||||
|
<th>원가 합계</th>
|
||||||
|
<th>판관비 합계</th>
|
||||||
|
<th>원가인건비</th>
|
||||||
|
<th>원가외주비</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in monthly_summary %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ item.year }}</td>
|
||||||
|
<td>{{ item.month }}</td>
|
||||||
|
<td>{{ "{:,.0f}".format(item.cost_sum or 0) }}</td>
|
||||||
|
<td>{{ "{:,.0f}".format(item.sga_sum or 0) }}</td>
|
||||||
|
<td>{{ "{:,.0f}".format(item.labor_sum or 0) }}</td>
|
||||||
|
<td>{{ "{:,.0f}".format(item.outsourcing_sum or 0) }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% else %}
|
||||||
|
<div class="empty">월별 집계 데이터가 없습니다.</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="two-col">
|
||||||
|
<div class="stack">
|
||||||
|
<section class="panel">
|
||||||
|
<div class="section-title">
|
||||||
|
<h2>엑셀 업로드</h2>
|
||||||
|
<p>업로드 즉시 DB 저장</p>
|
||||||
|
</div>
|
||||||
|
<div class="upload-box">
|
||||||
|
<p>
|
||||||
|
업로드 파일은 이미지에 보인 열 형식 기준으로 읽습니다.
|
||||||
|
예: 결재상태, 가전표번호, 계정코드, 계정명칭, 차변공급가, 대변공급가, 지원부서코드,
|
||||||
|
지원부서명, 원가부서코드, 원가부서명, 적요1, 관리항목 등
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
현재 프로젝트 폴더에 있는 엑셀 파일은 서버 시작 시 DB가 비어 있으면 자동으로 적재됩니다.
|
||||||
|
</p>
|
||||||
|
<form action="/upload" method="post" enctype="multipart/form-data">
|
||||||
|
<div class="field">
|
||||||
|
<label for="excel_file">엑셀 파일 선택</label>
|
||||||
|
<input id="excel_file" type="file" name="excel_file" accept=".xlsx,.xlsm,.xltx,.xltm" required>
|
||||||
|
</div>
|
||||||
|
<div class="actions">
|
||||||
|
<button type="submit">엑셀을 DB에 저장</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="panel">
|
||||||
|
<div class="section-title">
|
||||||
|
<h2>{{ "데이터 수정" if edit_record.id else "DB 직접 입력" }}</h2>
|
||||||
|
<p>엑셀 없이도 직접 등록/수정 가능</p>
|
||||||
|
</div>
|
||||||
|
<form action="/records/save" method="post">
|
||||||
|
<input type="hidden" name="id" value="{{ edit_record.id }}">
|
||||||
|
<div class="form-grid">
|
||||||
|
{% for field_name, field_label in field_labels.items() %}
|
||||||
|
<div class="field {% if field_name in ['memo1', 'memo2', 'management_item'] %}field-wide{% endif %}">
|
||||||
|
<label for="{{ field_name }}">{{ field_label }}</label>
|
||||||
|
{% if field_name in ['memo1', 'memo2', 'management_item'] %}
|
||||||
|
<textarea id="{{ field_name }}" name="{{ field_name }}">{{ edit_record[field_name] }}</textarea>
|
||||||
|
{% elif field_name == 'posting_date' %}
|
||||||
|
<input id="{{ field_name }}" type="date" name="{{ field_name }}" value="{{ edit_record[field_name] }}">
|
||||||
|
{% elif field_name in ['debit_supply', 'debit_vat', 'credit_supply', 'credit_vat'] %}
|
||||||
|
<input id="{{ field_name }}" type="number" step="0.01" name="{{ field_name }}" value="{{ edit_record[field_name] }}">
|
||||||
|
{% else %}
|
||||||
|
<input id="{{ field_name }}" type="text" name="{{ field_name }}" value="{{ edit_record[field_name] }}">
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
<div class="actions">
|
||||||
|
<button type="submit">{{ "수정 내용을 저장" if edit_record.id else "새 데이터 저장" }}</button>
|
||||||
|
{% if edit_record.id %}
|
||||||
|
<a class="button-link button-secondary" href="/">수정 취소</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="stack">
|
||||||
|
<details class="panel">
|
||||||
|
<summary>
|
||||||
|
<span>집계 대상 사업</span>
|
||||||
|
<span style="font-size:14px;color:var(--muted);">검색해서 펼쳐보기</span>
|
||||||
|
</summary>
|
||||||
|
<div class="search-box">
|
||||||
|
<input type="text" id="support-business-search" placeholder="지원부서코드 또는 사업명을 입력하세요.">
|
||||||
|
</div>
|
||||||
|
<div class="table-wrap">
|
||||||
|
{% if support_businesses %}
|
||||||
|
<table id="support-business-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>지원부서코드</th>
|
||||||
|
<th>사업명</th>
|
||||||
|
<th>행 수</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in support_businesses %}
|
||||||
|
<tr data-search="{{ item.support_dept_code }} {{ item.support_dept_name }}">
|
||||||
|
<td class="mono">{{ item.support_dept_code }}</td>
|
||||||
|
<td>{{ item.support_dept_name }}</td>
|
||||||
|
<td>{{ item.row_count }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% else %}
|
||||||
|
<div class="empty">아직 표시할 사업 데이터가 없습니다. 엑셀 업로드 또는 수동 입력을 먼저 진행해주세요.</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<details class="panel">
|
||||||
|
<summary>
|
||||||
|
<span>사업별 연도/월 사용 비용</span>
|
||||||
|
<span style="font-size:14px;color:var(--muted);">검색해서 펼쳐보기</span>
|
||||||
|
</summary>
|
||||||
|
<div class="search-box">
|
||||||
|
<input type="text" id="business-cost-search" placeholder="연도, 월, 지원부서코드, 사업명으로 검색하세요.">
|
||||||
|
</div>
|
||||||
|
<div class="table-wrap">
|
||||||
|
{% if business_monthly_summary %}
|
||||||
|
<table id="business-cost-table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>연도</th>
|
||||||
|
<th>월</th>
|
||||||
|
<th>지원부서코드</th>
|
||||||
|
<th>사업명</th>
|
||||||
|
<th>원가</th>
|
||||||
|
<th>판관비</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for item in business_monthly_summary %}
|
||||||
|
<tr data-search="{{ item.year }} {{ item.month }} {{ item.support_dept_code }} {{ item.support_dept_name }}">
|
||||||
|
<td>{{ item.year }}</td>
|
||||||
|
<td>{{ item.month }}</td>
|
||||||
|
<td class="mono">{{ item.support_dept_code }}</td>
|
||||||
|
<td>{{ item.support_dept_name }}</td>
|
||||||
|
<td>{{ "{:,.0f}".format(item.cost_sum or 0) }}</td>
|
||||||
|
<td>{{ "{:,.0f}".format(item.sga_sum or 0) }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% else %}
|
||||||
|
<div class="empty">사업별 월 집계 데이터가 없습니다.</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
function bindTableSearch(inputId, tableId) {
|
||||||
|
const input = document.getElementById(inputId);
|
||||||
|
const table = document.getElementById(tableId);
|
||||||
|
if (!input || !table) return;
|
||||||
|
const rows = Array.from(table.querySelectorAll("tbody tr"));
|
||||||
|
input.addEventListener("input", () => {
|
||||||
|
const keyword = input.value.trim().toLowerCase();
|
||||||
|
rows.forEach((row) => {
|
||||||
|
const haystack = (row.dataset.search || row.textContent || "").toLowerCase();
|
||||||
|
row.style.display = !keyword || haystack.includes(keyword) ? "" : "none";
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
bindTableSearch("support-business-search", "support-business-table");
|
||||||
|
bindTableSearch("business-cost-search", "business-cost-table");
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Reference in New Issue
Block a user