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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sqlite3
|
| 3 |
+
import random
|
| 4 |
+
import tempfile
|
| 5 |
+
from io import BytesIO
|
| 6 |
+
from datetime import date, datetime
|
| 7 |
+
|
| 8 |
+
import pandas as pd
|
| 9 |
+
import streamlit as st
|
| 10 |
+
from openpyxl import Workbook
|
| 11 |
+
from openpyxl.styles import Font, Alignment, Border, Side, PatternFill
|
| 12 |
+
from openpyxl.utils import get_column_letter
|
| 13 |
+
from openpyxl.drawing.image import Image as XLImage
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
# =========================================================
|
| 17 |
+
# ๊ธ์ฌ์ ๊ณต์ง์นจ ๊ต์ก์ผ์ง ํตํฉ์ฐ๋ ์์ฑ๊ธฐ
|
| 18 |
+
# - Client Center DB์ ๊ฐ์ clients.db ์ฌ์ฉ
|
| 19 |
+
# - ๊ธฐ๊ด์ ๋ณด/์ฐธ์์(์ง์ข
๋ณ ์
๋ ฅ)/๊ฐ์ฌ/๊ต์ก์๋ฃ ์ฒจ๋ถ/๊ต์ก๊ฒฐ๊ณผ/ํ๊ฐ ์ ํฉ๋ ์ ๊ฒ
|
| 20 |
+
# - ๊ฒฐ์ฌ๋ผ์ธ ๋ด๋น์/์์ค์ฅ 2์นธ, ์ง์ ๋ถํ ๋น์นธ ์์ด ์ถ๋ ฅ
|
| 21 |
+
# =========================================================
|
| 22 |
+
|
| 23 |
+
st.set_page_config(
|
| 24 |
+
page_title="๊ธ์ฌ์ ๊ณต์ง์นจ ๊ต์ก์ผ์ง",
|
| 25 |
+
page_icon="๐",
|
| 26 |
+
layout="wide"
|
| 27 |
+
)
|
| 28 |
+
|
| 29 |
+
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 30 |
+
|
| 31 |
+
DB_CANDIDATES = [
|
| 32 |
+
os.path.join(CURRENT_DIR, "data", "clients.db"),
|
| 33 |
+
os.path.join(CURRENT_DIR, "..", "Client Center", "data", "clients.db"),
|
| 34 |
+
os.path.join(CURRENT_DIR, "..", "ClientCenter", "data", "clients.db"),
|
| 35 |
+
os.path.join(CURRENT_DIR, "..", "Client_Center", "data", "clients.db"),
|
| 36 |
+
]
|
| 37 |
+
|
| 38 |
+
DB_PATH = None
|
| 39 |
+
for p in DB_CANDIDATES:
|
| 40 |
+
if os.path.exists(p):
|
| 41 |
+
DB_PATH = p
|
| 42 |
+
break
|
| 43 |
+
|
| 44 |
+
if DB_PATH is None:
|
| 45 |
+
os.makedirs(os.path.join(CURRENT_DIR, "data"), exist_ok=True)
|
| 46 |
+
DB_PATH = os.path.join(CURRENT_DIR, "data", "clients.db")
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
# -----------------------------
|
| 50 |
+
# ๋์์ธ
|
| 51 |
+
# -----------------------------
|
| 52 |
+
st.markdown("""
|
| 53 |
+
<style>
|
| 54 |
+
.block-container { padding-top: 2rem; }
|
| 55 |
+
.hero {
|
| 56 |
+
background: linear-gradient(135deg, #7C2D12, #EA580C);
|
| 57 |
+
padding: 30px;
|
| 58 |
+
border-radius: 22px;
|
| 59 |
+
text-align: center;
|
| 60 |
+
margin-bottom: 22px;
|
| 61 |
+
}
|
| 62 |
+
.hero h1 { color: white; margin: 0; font-size: 36px; }
|
| 63 |
+
.hero p { color: white; margin-top: 10px; font-size: 18px; }
|
| 64 |
+
.notice {
|
| 65 |
+
background: #fff8e1;
|
| 66 |
+
border-left: 7px solid #f9a825;
|
| 67 |
+
padding: 15px;
|
| 68 |
+
border-radius: 12px;
|
| 69 |
+
margin-bottom: 18px;
|
| 70 |
+
}
|
| 71 |
+
.okbox {
|
| 72 |
+
background: #e8f5e9;
|
| 73 |
+
border-left: 7px solid #43a047;
|
| 74 |
+
padding: 14px;
|
| 75 |
+
border-radius: 12px;
|
| 76 |
+
margin-bottom: 14px;
|
| 77 |
+
}
|
| 78 |
+
.warnbox {
|
| 79 |
+
background: #fff3e0;
|
| 80 |
+
border-left: 7px solid #fb8c00;
|
| 81 |
+
padding: 14px;
|
| 82 |
+
border-radius: 12px;
|
| 83 |
+
margin-bottom: 14px;
|
| 84 |
+
}
|
| 85 |
+
</style>
|
| 86 |
+
""", unsafe_allow_html=True)
|
| 87 |
+
|
| 88 |
+
st.markdown("""
|
| 89 |
+
<div class="hero">
|
| 90 |
+
<h1>๐ ๊ธ์ฌ์ ๊ณต์ง์นจ ๊ต์ก์ผ์ง ์์ฑ๊ธฐ</h1>
|
| 91 |
+
<p>์ข
์ฌ์ ๊ธ์ฌ์ ๊ณต์ง์นจ ๊ต์ก์ผ์ง๋ฅผ ์์ฑํ๊ณ ์ง์ข
๋ณ ์ฐธ์ ๋ช
๋จ๊ณผ ์ด์๊ธฐ๋ก์ ๊ด๋ฆฌํฉ๋๋ค.</p>
|
| 92 |
+
</div>
|
| 93 |
+
""", unsafe_allow_html=True)
|
| 94 |
+
|
| 95 |
+
st.markdown("""
|
| 96 |
+
<div class="notice">
|
| 97 |
+
<strong>ํ์ ๊ตฌ์กฐ:</strong> ๊ต์ก๋ช
, ๊ต์ก์ผ์, ์ฅ์, ๊ฐ์ฌ๋ช
, ์ง์ข
๋ณ ์ฐธ์์ ๋ช
๋จ, ๊ต์ก๋ชฉ์ , ๊ต์ก๋ด์ฉ, ๊ต์ก์๋ฃ ์ฒจ๋ถ, ๊ต์ก๊ฒฐ๊ณผ, ํ๊ฐ ์ ํฉ๋ ์ ๊ฒ, ๊ฒฐ์ฌ๋ผ์ธ์ ํฌํจํฉ๋๋ค.
|
| 98 |
+
</div>
|
| 99 |
+
""", unsafe_allow_html=True)
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
# -----------------------------
|
| 103 |
+
# DB
|
| 104 |
+
# -----------------------------
|
| 105 |
+
def get_conn():
|
| 106 |
+
return sqlite3.connect(DB_PATH, check_same_thread=False)
|
| 107 |
+
|
| 108 |
+
def init_db():
|
| 109 |
+
conn = get_conn()
|
| 110 |
+
cur = conn.cursor()
|
| 111 |
+
|
| 112 |
+
cur.execute("""
|
| 113 |
+
CREATE TABLE IF NOT EXISTS education_records (
|
| 114 |
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
| 115 |
+
institution_name TEXT,
|
| 116 |
+
institution_type TEXT,
|
| 117 |
+
education_title TEXT,
|
| 118 |
+
guideline_items TEXT,
|
| 119 |
+
education_date TEXT,
|
| 120 |
+
education_time TEXT,
|
| 121 |
+
education_place TEXT,
|
| 122 |
+
instructor_name TEXT,
|
| 123 |
+
instructor_position TEXT,
|
| 124 |
+
attendees TEXT,
|
| 125 |
+
absent_staff TEXT,
|
| 126 |
+
education_method TEXT,
|
| 127 |
+
education_purpose TEXT,
|
| 128 |
+
education_content TEXT,
|
| 129 |
+
education_materials TEXT,
|
| 130 |
+
education_result TEXT,
|
| 131 |
+
followup_plan TEXT,
|
| 132 |
+
evaluation_score INTEGER,
|
| 133 |
+
missing_items TEXT,
|
| 134 |
+
compliance_result TEXT,
|
| 135 |
+
created_at TEXT
|
| 136 |
+
)
|
| 137 |
+
""")
|
| 138 |
+
|
| 139 |
+
conn.commit()
|
| 140 |
+
conn.close()
|
| 141 |
+
|
| 142 |
+
def save_education_record(data):
|
| 143 |
+
conn = get_conn()
|
| 144 |
+
cur = conn.cursor()
|
| 145 |
+
cur.execute("""
|
| 146 |
+
INSERT INTO education_records (
|
| 147 |
+
institution_name, institution_type, education_title, guideline_items,
|
| 148 |
+
education_date, education_time, education_place,
|
| 149 |
+
instructor_name, instructor_position, attendees, absent_staff,
|
| 150 |
+
education_method, education_purpose, education_content,
|
| 151 |
+
education_materials, education_result, followup_plan,
|
| 152 |
+
evaluation_score, missing_items, compliance_result, created_at
|
| 153 |
+
)
|
| 154 |
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
| 155 |
+
""", (
|
| 156 |
+
data["institution_name"], data["institution_type"], data["education_title"],
|
| 157 |
+
data["guideline_items"], data["education_date"], data["education_time"],
|
| 158 |
+
data["education_place"], data["instructor_name"], data["instructor_position"],
|
| 159 |
+
data["attendees"], data["absent_staff"], data["education_method"],
|
| 160 |
+
data["education_purpose"], data["education_content"], data["education_materials"],
|
| 161 |
+
data["education_result"], data["followup_plan"], data["evaluation_score"],
|
| 162 |
+
data["missing_items"], data["compliance_result"], datetime.now().strftime("%Y-%m-%d %H:%M:%S"),
|
| 163 |
+
))
|
| 164 |
+
conn.commit()
|
| 165 |
+
conn.close()
|
| 166 |
+
|
| 167 |
+
def load_education_records():
|
| 168 |
+
conn = get_conn()
|
| 169 |
+
try:
|
| 170 |
+
df = pd.read_sql_query("SELECT * FROM education_records ORDER BY id DESC", conn)
|
| 171 |
+
except Exception:
|
| 172 |
+
df = pd.DataFrame()
|
| 173 |
+
conn.close()
|
| 174 |
+
return df
|
| 175 |
+
|
| 176 |
+
init_db()
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
# -----------------------------
|
| 180 |
+
# ๊ธ์ฌ์ ๊ณต์ง์นจ
|
| 181 |
+
# -----------------------------
|
| 182 |
+
GUIDELINES = {
|
| 183 |
+
"01. ์ข
์ฌ์ ์ค๋ฆฌ์ง์นจ": {
|
| 184 |
+
"purpose": "์ข
์ฌ์์ ์ง์
์ค๋ฆฌ์ ์๊ธ์ ์กด์ค ํ๋๋ฅผ ๊ฐํํ์ฌ ์ ๋ฌธ์ ์ธ ๊ธ์ฌ์ ๊ณต์ด ์ด๋ฃจ์ด์ง๋๋ก ํ๋ค.",
|
| 185 |
+
"content": ["์๊ธ์ ์ธ๊ฒฉ ์กด์ค๊ณผ ์ฌ์ํ ๋ณดํธ", "๊ธ์ฌ์ ๊ณต ๋ฒ์ ์ค์์ ๋ถ๋น์๊ตฌ ๋์", "์ ๋ฌธ์ง ์ข
์ฌ์๋ก์์ ์ฑ
์๊ณผ ๋ณด๊ณ ์ฒด๊ณ", "์๋น์ค ์ ๊ณต ์ค ๋น๋ฐ์ ์ง์ ๊ณต์ ํ ํ๋"],
|
| 186 |
+
},
|
| 187 |
+
"02. ๋
ธ์ธ์ธ๊ถ๋ณดํธ์ง์นจ": {
|
| 188 |
+
"purpose": "์๊ธ์์ ๊ถ๋ฆฌ์ ์๊ธฐ๊ฒฐ์ ๊ถ์ ์กด์คํ๊ณ ์ธ๊ถ์นจํด๋ฅผ ์๋ฐฉํ๋ค.",
|
| 189 |
+
"content": ["๋
ธ์ธ ์ธ๊ถ์ ๊ธฐ๋ณธ ์์น", "์ ์ฒด์ ยท์ ์์ ยท์ธ์ด์ ์ธ๊ถ์นจํด ์๋ฐฉ", "์๊ธ์์ ์์ฌํํ๊ณผ ์ ํ๊ถ ์กด์ค", "์ธ๊ถ์นจํด ๋ฐ์ ์ ๋ณด๊ณ ๋ฐ ์กฐ์น ์ ์ฐจ"],
|
| 190 |
+
},
|
| 191 |
+
"03. ๋
ธ์ธํ๋์๋ฐฉ์ง์นจ": {
|
| 192 |
+
"purpose": "๋
ธ์ธํ๋ ์ ํ์ ์ดํดํ๊ณ ์์ฌ์ฌ๋ก ๋ฐ๊ฒฌ ์ ์ฆ์ ๋ณด๊ณ ํ ์ ์๋๋ก ํ๋ค.",
|
| 193 |
+
"content": ["์ ์ฒด์ ยท์ ์์ ยท๊ฒฝ์ ์ ํ๋ ๋ฐ ๋ฐฉ์์ ์ ํ", "ํ๋ ์์ฌ ์งํ ํ์ธ", "์ ๊ณ ์๋ฌด์ ์ ๊ณ ์ ์ฐจ", "ํ๋ ์๋ฐฉ์ ์ํ ์ข
์ฌ์ ํ๋์์น"],
|
| 194 |
+
},
|
| 195 |
+
"04. ๊ฐ์ธ์ ๋ณด๋ณดํธ์ง์นจ": {
|
| 196 |
+
"purpose": "์๊ธ์์ ๋ณดํธ์์ ๊ฐ์ธ์ ๋ณด๋ฅผ ์์ ํ๊ฒ ๊ด๋ฆฌํ๊ณ ์ ์ถ์ ์๋ฐฉํ๋ค.",
|
| 197 |
+
"content": ["๊ฐ์ธ์ ๋ณด ์์งยท์ด์ฉยท๋ณด๊ด ์์น", "๋ฌธ์ ๋ฐ ์ ์ฐ์๋ฃ ์ ๊ทผ๊ด๋ฆฌ", "์ฌ์งยท์์ ์ฌ์ฉ ์ ๋์์ ๋ณดํธ์กฐ์น", "๊ฐ์ธ์ ๋ณด ์ ์ถ ์ ๋ณด๊ณ ์ ์ฐจ"],
|
| 198 |
+
},
|
| 199 |
+
"05. ์ฑํญ๋ ฅ์๋ฐฉ ๋ฐ ๋์์ง์นจ": {
|
| 200 |
+
"purpose": "์๊ธ์์ ์ข
์ฌ์์ ์ฑ์ ์๊ธฐ๊ฒฐ์ ๊ถ์ ๋ณดํธํ๊ณ ์ฑํฌ๋กฑยท์ฑํญ๋ ฅ์ ์๋ฐฉํ๋ค.",
|
| 201 |
+
"content": ["์ฑํฌ๋กฑยท์ฑํญ๋ ฅ์ ๊ฐ๋
๊ณผ ์ฌ๋ก", "๋ชฉ์ยท๋ฐฐ๋ณยท์ ์ฒด์ง์ ์ ์ ์์ฌํญ", "๋ถ์พ๊ฐ ํํ ์ ์ฆ์ ์ค๋จ ๋ฐ ๋ณด๊ณ ", "ํผํด ๋ฐ์ ์ ๋ณดํธ์กฐ์น์ ๋ณด๊ณ ์ฒด๊ณ"],
|
| 202 |
+
},
|
| 203 |
+
"06. ์๊ธ์ํฉ๋์์ง์นจ": {
|
| 204 |
+
"purpose": "๋์, ํธํก๊ณค๋, ์์์ ํ ๋ฑ ์๊ธ์ํฉ ๋ฐ์ ์ ์ ์ํ๊ณ ์ ์ ํ๊ฒ ๋์ํ๋ค.",
|
| 205 |
+
"content": ["์๊ธ์ํฉ ์ ํ๊ณผ ์ด๊ธฐ ํ์ธ", "119 ์ ๊ณ ๋ฐ ๋ณดํธ์ ์ฐ๋ฝ ์ ์ฐจ", "๊ธฐ๊ด ๋ณด๊ณ ์ฒด๊ณ์ ๊ธฐ๋ก ๋ฐฉ๋ฒ", "์ฌํ์์์ ๋ฐ ๊ธฐ๋ณธ ์๊ธ์ฒ์น ์ ์์ฌํญ"],
|
| 206 |
+
},
|
| 207 |
+
"07. ๊ฐ์ผ์๋ฐฉ ๋ฐ ๊ด๋ฆฌ์ง์นจ": {
|
| 208 |
+
"purpose": "๊ฐ์ผ๋ณ ์ ํ๋ฅผ ์๋ฐฉํ๊ณ ์๊ธ์์ ์ข
์ฌ์์ ๊ฑด๊ฐ์ ๋ณดํธํ๋ค.",
|
| 209 |
+
"content": ["์์์๊ณผ ๊ฐ์ธ๋ณดํธ๊ตฌ ์ฌ์ฉ", "๋ฐ์ดยทํธํก๊ธฐ ์ฆ์ ํ์ธ๊ณผ ๊ฒฉ๋ฆฌ ์๋ด", "ํ๊ฒฝ์๋
๋ฐ ํ๊ธฐ๊ด๋ฆฌ", "๊ฐ์ผ ์์ฌ ์ ๋ณด๊ณ ๋ฐ ์กฐ์น"],
|
| 210 |
+
},
|
| 211 |
+
"08. ์์ฐฝ์๋ฐฉ์ง์นจ": {
|
| 212 |
+
"purpose": "์์ฐฝ ์ํ์์ธ์ ์กฐ๊ธฐ์ ๋ฐ๊ฒฌํ๊ณ ์ฒด์๋ณ๊ฒฝ๊ณผ ํผ๋ถ๊ด์ฐฐ์ ํตํด ์์ฐฝ์ ์๋ฐฉํ๋ค.",
|
| 213 |
+
"content": ["์์ฐฝ ์ํ์์ธ๊ณผ ํธ๋ฐ๋ถ์", "์ฒด์๋ณ๊ฒฝ๊ณผ ์๋ฐ ์ํ", "ํผ๋ถ ๋ฐ์ ยท์์ฒ ๊ด์ฐฐ ๋ฐ ๋ณด๊ณ ", "์์ยท์๋ถ์ญ์ทจ์ ์ฒญ๊ฒฐ๊ด๋ฆฌ"],
|
| 214 |
+
},
|
| 215 |
+
"09. ๋์์๋ฐฉ์ง์นจ": {
|
| 216 |
+
"purpose": "์๊ธ์์ ๋์ ์ํ์ ์ค์ด๊ณ ์์ ํ ์ด๋๊ณผ ์ํํ๊ฒฝ์ ์ ์งํ๋ค.",
|
| 217 |
+
"content": ["๋์ ์ํ์์ธ ํ์ธ", "๋ณดํ๋ณด์กฐ์ ํ์ฅ์ค ์ด๋ ์ง์", "ํ๊ฒฝ์ ๋ฆฌ์ ๋ฏธ๋๋ผ ์๋ฐฉ", "๋์ ๋ฐ์ ์ ์กฐ์น์ ๊ธฐ๋ก"],
|
| 218 |
+
},
|
| 219 |
+
"10. ์น๋งค์๋ฐฉ ๋ฐ ๊ด๋ฆฌ์ง์นจ": {
|
| 220 |
+
"purpose": "์ธ์ง๊ธฐ๋ฅ ์ ํ ์๊ธ์์ ํน์ฑ์ ์ดํดํ๊ณ ์์ ์ ์ธ ๋๋ด์ ์ ๊ณตํ๋ค.",
|
| 221 |
+
"content": ["์น๋งค ์ฆ์๊ณผ ํ๋์ฌ๋ฆฌ์ฆ์ ์ดํด", "๋ฐ๋ณต์ค๋ช
๊ณผ ์์ ์ ํ๊ฒฝ ์ ๊ณต", "์ธ์งํ๋๊ณผ ์ผ์์ํ ์ง์", "๋ฐฐํยท๋ถ์ยท๊ณต๊ฒฉ์ฑ ๋์ ๋ฐฉ๋ฒ"],
|
| 222 |
+
},
|
| 223 |
+
"11. ๊ทผ๊ณจ๊ฒฉ๊ณ์งํ ์๋ฐฉ์ง์นจ": {
|
| 224 |
+
"purpose": "์ข
์ฌ์์ ํ๋ฆฌยท์ด๊นจยท์๋ชฉ ์์์ ์๋ฐฉํ๊ณ ์์ ํ ์
๋ฌด์ํ ๋ฐฉ๋ฒ์ ์ตํ๋ค.",
|
| 225 |
+
"content": ["๊ทผ๊ณจ๊ฒฉ๊ณ์งํ ์ํ์์ธ", "์ด๋ยท์ฒด์๋ณ๊ฒฝ ์ ์ฌ๋ฐ๋ฅธ ์์ธ", "๋ณด์กฐ๋๊ตฌ ํ์ฉ๊ณผ 2์ธ ํ์กฐ", "ํต์ฆ ๋ฐ์ ์ ๋ณด๊ณ ์ ์
๋ฌด์กฐ์ "],
|
| 226 |
+
},
|
| 227 |
+
"12. ์ข
์ฌ์ ์ธ๊ถ์นจํด ์๋ฐฉ์ง์นจ": {
|
| 228 |
+
"purpose": "์ข
์ฌ์์ ๋ํ ํญ์ธยทํญํยท์ฑํฌ๋กฑ ๋ฑ ์ธ๊ถ์นจํด๋ฅผ ์๋ฐฉํ๊ณ ๋ณดํธ์ฒด๊ณ๋ฅผ ์ดํดํ๋ค.",
|
| 229 |
+
"content": ["์ข
์ฌ์ ์ธ๊ถ์นจํด ์ ํ", "๋ถ๋น์๊ตฌ์ ํญ์ธยทํญํ ๋์", "๊ณ ์ถฉ ์ ์์ ๊ธฐ๊ด ๋ณด๏ฟฝ๏ฟฝ๏ฟฝ์กฐ์น", "์ฌ๋ฐ๋ฐฉ์ง๋ฅผ ์ํ ๊ธฐ๋ก๊ณผ ๋ณด๊ณ "],
|
| 230 |
+
},
|
| 231 |
+
"13. ๊ณ ์ถฉ์ฒ๋ฆฌ ๋ฐ ์ผ๊ฐ๊ทผ๋ฌด์ง์นจ": {
|
| 232 |
+
"purpose": "์๊ธ์ยท๋ณดํธ์ยท์ข
์ฌ์ ๊ณ ์ถฉ์ ์ฒด๊ณ์ ์ผ๋ก ์ฒ๋ฆฌํ๊ณ ์ผ๊ฐ๊ทผ๋ฌด ์ ์์ ๊ด๋ฆฌ ์์น์ ์ค์ํ๋ค.",
|
| 233 |
+
"content": ["๊ณ ์ถฉ ์ ์์ ์ฒ๋ฆฌ ์ ์ฐจ", "๋ฏผ์ ์๋ฐฉ๊ณผ ์๋ด๊ธฐ๋ก ๊ด๋ฆฌ", "์ผ๊ฐ๊ทผ๋ฌด ์ ์์ฐฐยท์๊ธ์ํฉ ๋์", "์ผ๊ฐ ํน์ด์ฌํญ ๋ณด๊ณ ๋ฐ ์ธ์์ธ๊ณ"],
|
| 234 |
+
},
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
METHODS = ["์งํฉ๊ต์ก", "๊ฐ๋ณ๊ต์ก", "์จ๋ผ์ธ๊ต์ก", "ํ์๊ต์ก", "์๋ฃ๋ฐฐํฌ ํ ํ์ธ", "ํ์ฅ์ค์ต ๋ณํ"]
|
| 238 |
+
|
| 239 |
+
|
| 240 |
+
# -----------------------------
|
| 241 |
+
# ์์ฑ ๋ก์ง
|
| 242 |
+
# -----------------------------
|
| 243 |
+
def build_education_text(selected_items, institution_type, method, custom_content):
|
| 244 |
+
if not selected_items:
|
| 245 |
+
return "", ""
|
| 246 |
+
|
| 247 |
+
purpose_lines = []
|
| 248 |
+
content_lines = []
|
| 249 |
+
for item in selected_items:
|
| 250 |
+
g = GUIDELINES[item]
|
| 251 |
+
purpose_lines.append(f"- {item}: {g['purpose']}")
|
| 252 |
+
content_lines.append(f"[{item}]")
|
| 253 |
+
for c in g["content"]:
|
| 254 |
+
content_lines.append(f"- {c}")
|
| 255 |
+
content_lines.append("")
|
| 256 |
+
|
| 257 |
+
institution_note = {
|
| 258 |
+
"๋ฐฉ๋ฌธ์์": "๋ฐฉ๋ฌธ์๋น์ค ํ์ฅ์์ ๋จ๋
๊ทผ๋ฌด ์ค ๋ฐ์ํ ์ ์๋ ์๊ธ์ํฉ, ๊ฐ์ธ์ ๋ณด๋ณดํธ, ๋ณดํธ์ ์์ฒญ ๋์์ ์ค์ฌ์ผ๋ก ๊ต์กํจ.",
|
| 259 |
+
"๋ฐฉ๋ฌธ๋ชฉ์": "๋ชฉ์์ง์ ๊ณผ์ ์์ ์ ์ฒด๋
ธ์ถ, ๋์, ํผ๋ถ์ํ ํ์ธ, ๊ฐ์ผ์๋ฐฉ, ์๊ธ์ํฉ ๋์์ ์ค์ฌ์ผ๋ก ๊ต์กํจ.",
|
| 260 |
+
"๋ฐฉ๋ฌธ๊ฐํธ": "๊ฑด๊ฐ์ํ ๊ด์ฐฐ, ๊ฐ์ผ๊ด๋ฆฌ, ๊ฐ์ธ์ ๋ณด๋ณดํธ, ์๋ฃ์ฐ๊ณ ๋ฐ ์๊ธ์ํฉ ๋์์ ์ค์ฌ์ผ๋ก ๊ต์กํจ.",
|
| 261 |
+
"์ฃผ๊ฐ๋ณดํธ": "์ผํฐ ๋ด ๋จ์ฒด์ํ, ํ๋ก๊ทธ๋จ ์ฐธ์ฌ, ์ก์์์ , ๋์ยท๊ฐ์ผ์๋ฐฉ, ์๊ธ์ ๊ฐ ๊ฐ๋ฑ ์๋ฐฉ์ ์ค์ฌ์ผ๋ก ๊ต์กํจ.",
|
| 262 |
+
"์์์": "์
์์ํ ์ ๋ฐ์ ์ธ๊ถ๋ณดํธ, ์์ฐฝยท๋์ยท๊ฐ์ผ์๋ฐฉ, ์ผ๊ฐ๊ทผ๋ฌด, ์๊ธ์ํฉ ๋์์ ์ค์ฌ์ผ๋ก ๊ต์กํจ.",
|
| 263 |
+
"๊ณต๋์ํ๊ฐ์ ": "์๊ท๋ชจ ๊ณต๋์ํ ์ค ์ธ๊ถ๋ณดํธ, ์ ์์ง์, ์ผ๊ฐ์์ , ๊ฐ์ผ์๋ฐฉ, ๊ณ ์ถฉ์ฒ๋ฆฌ๋ฅผ ์ค์ฌ์ผ๋ก ๊ต์กํจ.",
|
| 264 |
+
}.get(institution_type, "")
|
| 265 |
+
|
| 266 |
+
purpose = "๊ต์ก ๋ชฉ์ \n" + "\n".join(purpose_lines)
|
| 267 |
+
|
| 268 |
+
content = f"""
|
| 269 |
+
[๊ต์ก๋ฐฉ๋ฒ]
|
| 270 |
+
{method}
|
| 271 |
+
|
| 272 |
+
[๊ธฐ๊ด์ ํ๋ณ ๊ต์ก ์ค์ ]
|
| 273 |
+
{institution_note}
|
| 274 |
+
|
| 275 |
+
[๊ต์ก๋ด์ฉ]
|
| 276 |
+
{chr(10).join(content_lines)}
|
| 277 |
+
|
| 278 |
+
[๊ธฐ๊ด ์ถ๊ฐ ๊ต์ก๋ด์ฉ]
|
| 279 |
+
{custom_content or '๊ธฐ๊ด ์ด์๊ท์ ๊ณผ ์ข
์ฌ์ ์
๋ฌด์์น์ ๋ฐ๋ผ ์ค์ ์ฌ๋ก ์ค์ฌ์ผ๋ก ๊ต์ก์ ์งํํจ.'}
|
| 280 |
+
""".strip()
|
| 281 |
+
|
| 282 |
+
return purpose, content
|
| 283 |
+
|
| 284 |
+
|
| 285 |
+
def build_result_text(selected_items, att_dict, absent_staff, method):
|
| 286 |
+
item_text = ", ".join(selected_items)
|
| 287 |
+
|
| 288 |
+
# ์ด๋ฆ ๊ฐฏ์ ๋๋ต์ ์นด์ดํธ (์ผํ๋ ๋์ด์ฐ๊ธฐ ๊ธฐ์ค)
|
| 289 |
+
total_names = 0
|
| 290 |
+
for names in att_dict.values():
|
| 291 |
+
total_names += len([n for n in names.replace(',', ' ').split() if n.strip()])
|
| 292 |
+
|
| 293 |
+
absent_text = absent_staff.strip() or "๋ฏธ์ฐธ์์ ์์"
|
| 294 |
+
|
| 295 |
+
variants = [
|
| 296 |
+
f"{item_text} ๊ต์ก์ ํตํด ์ข
์ฌ์์ ์ง์นจ ์ดํด๋๋ฅผ ๋์ด๊ณ ์ค์ ๊ธ์ฌ์ ๊ณต ๊ณผ์ ์์ ์ค์ํด์ผ ํ ๋ณด๊ณ ์ฒด๊ณ์ ํ๋์์น์ ์ฌํ์ธํ์๋ค.",
|
| 297 |
+
f"์ฐธ์์๋ค์ {item_text}์ ์ฃผ์ ๋ด์ฉ์ ํ์ธํ์์ผ๋ฉฐ, ์๊ธ์ ์์ ๊ณผ ๊ถ๋ฆฌ๋ณดํธ๋ฅผ ์ํ ์ค์ฒ๋ฐฉ๋ฒ์ ๊ณต์ ํ์๋ค.",
|
| 298 |
+
f"๊ต์ก ํ ์ง์์๋ต์ ํตํด ํ์ฅ์์ ๋ฐ์ํ ์ ์๋ ์ฌ๋ก๋ฅผ ์ ๊ฒํ์๊ณ , ์ง์นจ ๋ฏธ์ค์ ์๋ฐฉ๊ณผ ๊ธฐ๋ก๊ด๋ฆฌ์ ์ค์์ฑ์ ํ์ธํ์๋ค.",
|
| 299 |
+
]
|
| 300 |
+
|
| 301 |
+
return f"""
|
| 302 |
+
๊ต์ก๊ฒฐ๊ณผ, ์ด {total_names}๋ช
์ ์ข
์ฌ์๊ฐ {method} ๋ฐฉ์์ผ๋ก ๊ต์ก์ ์ฐธ์ฌํ์๋ค.
|
| 303 |
+
{random.choice(variants)}
|
| 304 |
+
|
| 305 |
+
์ฐธ์์ ์ ์์ด ๊ต์ก๋ด์ฉ์ ์ ์์งํ์์ผ๋ฉฐ, ๊ต์ก์๋ฃ์ ์ ์๋ ์ง์นจ ๋ด์ฉ์ ์ค์ ๊ธ์ฌ์ ๊ณต ๊ณผ์ ์์ ์ค์ํ๊ธฐ๋ก ํ์๋ค.
|
| 306 |
+
๊ธฐ๊ด์ ๊ธ์ฌ์ ๊ณต์ง์นจ ๊ต์ก์๋ฃ๋ฅผ ์ข
์ฌ์๊ฐ ์ฝ๊ฒ ํ์ธํ ์ ์๋ ์ฅ์์ ๊ณต๊ฐ ๊ฒ์ํ๊ณ , ์ข
์ฌ์๊ฐ ์์๋ก ์ง์นจ ๋ด์ฉ์ ํ์ธํ์ฌ ๊ธ์ฌ์ ๊ณต์ ๋ฐ์ํ ์ ์๋๋ก ๊ด๋ฆฌํ๋ค.
|
| 307 |
+
๋ํ ์ ๊ท์ง์, ๋ฏธ์ฐธ์์, ์ง์นจ ์์ง๊ฐ ๋ถ์กฑํ ์ข
์ฌ์์๊ฒ๋ ๋ณด์ถฉ๊ต์ก์ ์ค์ํ๊ณ , ๊ต์ก๋ด์ฉ์ด ํ์ฅ์์ ์ดํ๋๋์ง ์ง์์ ์ผ๋ก ๋ชจ๋ํฐ๋งํ๋ค.
|
| 308 |
+
|
| 309 |
+
๋ฏธ์ฐธ์์ ๊ด๋ฆฌ: {absent_text}
|
| 310 |
+
""".strip()
|
| 311 |
+
|
| 312 |
+
|
| 313 |
+
def evaluate_education(data):
|
| 314 |
+
required = {
|
| 315 |
+
"๊ต์ก๋ช
": bool(data["education_title"].strip()),
|
| 316 |
+
"๊ต์ก์ผ์": bool(data["education_date"]) and bool(data["education_time"].strip()),
|
| 317 |
+
"๊ต์ก์ฅ์": bool(data["education_place"].strip()),
|
| 318 |
+
"๊ฐ์ฌ๋ช
": bool(data["instructor_name"].strip()),
|
| 319 |
+
"๊ต์ก๋์/์ฐธ์์": bool(data["attendees"].strip()),
|
| 320 |
+
"๊ต์ก์ง์นจ ์ ํ": bool(data["guideline_items"].strip()),
|
| 321 |
+
"๊ต์ก๋ชฉ์ ": bool(data["education_purpose"].strip()),
|
| 322 |
+
"๊ต์ก๋ด์ฉ": bool(data["education_content"].strip()),
|
| 323 |
+
"๊ต์ก์๋ฃ ์ฒจ๋ถ/๋ช
์": bool(data["education_materials"].strip()),
|
| 324 |
+
"๊ต์ก๊ฒฐ๊ณผ": bool(data["education_result"].strip()),
|
| 325 |
+
"๋ฏธ์ฐธ์์ ๊ด๋ฆฌ": "๏ฟฝ๏ฟฝ๏ฟฝ์ฐธ์" in data["education_result"] or bool(data["absent_staff"].strip()),
|
| 326 |
+
"ํ์์กฐ์น": bool(data["followup_plan"].strip()),
|
| 327 |
+
}
|
| 328 |
+
|
| 329 |
+
score = int(sum(required.values()) / len(required) * 100)
|
| 330 |
+
missing = [k for k, v in required.items() if not v]
|
| 331 |
+
|
| 332 |
+
if score >= 90:
|
| 333 |
+
result = "ํ๊ฐ ์ ํฉ๋๊ฐ ๋์ต๋๋ค. ๊ต์ก์ผ์, ๊ฐ์ฌ, ์ฐธ์์, ๊ต์ก๋ด์ฉ, ๊ฒฐ๊ณผ ๋ฐ ํ์์กฐ์น๊ฐ ์ ๋ฐ์๋์์ต๋๋ค."
|
| 334 |
+
elif score >= 75:
|
| 335 |
+
result = "๋์ฒด๋ก ์ ํฉํ๋ ์ผ๋ถ ๋ณด์์ด ํ์ํฉ๋๋ค. ๋ถ์กฑ ํญ๋ชฉ์ ๋ณด์ํ๋ฉด ํ๊ฐ ๋์๋ ฅ์ด ๋์์ง๋๋ค."
|
| 336 |
+
else:
|
| 337 |
+
result = "๋ณด์์ด ํ์ํฉ๋๋ค. ์ฐธ์์ ๋ช
๋จ, ๊ต์ก์๋ฃ, ๊ต์ก๊ฒฐ๊ณผ, ๋ฏธ์ฐธ์์ ๊ด๋ฆฌ๊ฐ ๊ตฌ์ฒด์ ์ผ๋ก ๋ค์ด๊ฐ์ผ ํฉ๋๋ค."
|
| 338 |
+
|
| 339 |
+
return score, missing, result
|
| 340 |
+
|
| 341 |
+
|
| 342 |
+
def save_uploaded_materials(uploaded_files):
|
| 343 |
+
paths = []
|
| 344 |
+
names = []
|
| 345 |
+
for file in (uploaded_files or [])[:3]:
|
| 346 |
+
suffix = os.path.splitext(file.name)[1].lower() or ".png"
|
| 347 |
+
temp_path = os.path.join(tempfile.gettempdir(), f"edu_material_{datetime.now().strftime('%Y%m%d%H%M%S%f')}{suffix}")
|
| 348 |
+
with open(temp_path, "wb") as f:
|
| 349 |
+
f.write(file.getbuffer())
|
| 350 |
+
paths.append(temp_path)
|
| 351 |
+
names.append(file.name)
|
| 352 |
+
return paths, names
|
| 353 |
+
|
| 354 |
+
|
| 355 |
+
# -----------------------------
|
| 356 |
+
# ์์
์ถ๋ ฅ (๋์์ธ ์ ๋ช
ํ ๋ฐ ์
์๋ฆผ ๋ฐฉ์ง)
|
| 357 |
+
# -----------------------------
|
| 358 |
+
def style_range(ws, cell_range, border_on=True, fill=None, font=None, alignment=None):
|
| 359 |
+
"""๋ณํฉ ์
ํฌํจ ๋ฒ์ ์ ์ฒด์ ์คํ์ผ ์ ์ฉ (๊ฒ์ ์ ํ
๋๋ฆฌ๋ก ์ ๋ช
ํ๊ฒ)"""
|
| 360 |
+
thin = Side(style="thin", color="000000")
|
| 361 |
+
border = Border(left=thin, right=thin, top=thin, bottom=thin)
|
| 362 |
+
|
| 363 |
+
cells = ws[cell_range]
|
| 364 |
+
if not isinstance(cells, tuple):
|
| 365 |
+
cells = ((cells,),)
|
| 366 |
+
|
| 367 |
+
for row in cells:
|
| 368 |
+
for cell in row:
|
| 369 |
+
if border_on:
|
| 370 |
+
cell.border = border
|
| 371 |
+
if fill:
|
| 372 |
+
cell.fill = fill
|
| 373 |
+
if font:
|
| 374 |
+
cell.font = font
|
| 375 |
+
if alignment:
|
| 376 |
+
cell.alignment = alignment
|
| 377 |
+
|
| 378 |
+
def write_title_with_approval(ws, title, title_fill, header_fill):
|
| 379 |
+
for col in range(1, 10):
|
| 380 |
+
ws.column_dimensions[get_column_letter(col)].width = 11.5
|
| 381 |
+
|
| 382 |
+
ws.merge_cells("A1:G2")
|
| 383 |
+
c = ws.cell(1, 1)
|
| 384 |
+
c.value = title
|
| 385 |
+
c.font = Font(name="Malgun Gothic", size=24, bold=True)
|
| 386 |
+
c.alignment = Alignment(horizontal="center", vertical="center")
|
| 387 |
+
style_range(ws, "A1:G2", fill=title_fill)
|
| 388 |
+
|
| 389 |
+
# ๊ฒฐ์ฌ๋ผ์ธ (์ฐ์ธก ์๋จ 2์นธ)
|
| 390 |
+
ws.cell(1, 8).value = "๋ด๋น์"
|
| 391 |
+
ws.cell(1, 9).value = "์์ค์ฅ"
|
| 392 |
+
ws.cell(2, 8).value = ""
|
| 393 |
+
ws.cell(2, 9).value = ""
|
| 394 |
+
|
| 395 |
+
for rr in [1, 2]:
|
| 396 |
+
for cc in [8, 9]:
|
| 397 |
+
cell = ws.cell(rr, cc)
|
| 398 |
+
cell.alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
|
| 399 |
+
if rr == 1:
|
| 400 |
+
cell.font = Font(name="Malgun Gothic", size=11, bold=True)
|
| 401 |
+
cell.fill = header_fill
|
| 402 |
+
else:
|
| 403 |
+
cell.font = Font(name="Malgun Gothic", size=11)
|
| 404 |
+
style_range(ws, f"{get_column_letter(cc)}{rr}:{get_column_letter(cc)}{rr}")
|
| 405 |
+
|
| 406 |
+
ws.row_dimensions[1].height = 28
|
| 407 |
+
ws.row_dimensions[2].height = 42
|
| 408 |
+
|
| 409 |
+
def write_info_row(ws, row, a, b, c, d, e, f, header_fill):
|
| 410 |
+
ws.cell(row, 1).value = a
|
| 411 |
+
ws.merge_cells(start_row=row, start_column=2, end_row=row, end_column=3)
|
| 412 |
+
ws.cell(row, 2).value = b
|
| 413 |
+
|
| 414 |
+
ws.cell(row, 4).value = c
|
| 415 |
+
ws.merge_cells(start_row=row, start_column=5, end_row=row, end_column=6)
|
| 416 |
+
ws.cell(row, 5).value = d
|
| 417 |
+
|
| 418 |
+
ws.cell(row, 7).value = e
|
| 419 |
+
ws.merge_cells(start_row=row, start_column=8, end_row=row, end_column=9)
|
| 420 |
+
ws.cell(row, 8).value = f
|
| 421 |
+
|
| 422 |
+
for col in [1, 4, 7]:
|
| 423 |
+
ws.cell(row, col).fill = header_fill
|
| 424 |
+
ws.cell(row, col).font = Font(name="Malgun Gothic", size=11, bold=True)
|
| 425 |
+
ws.cell(row, col).alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
|
| 426 |
+
|
| 427 |
+
for col in [2, 5, 8]:
|
| 428 |
+
ws.cell(row, col).font = Font(name="Malgun Gothic", size=11)
|
| 429 |
+
ws.cell(row, col).alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
|
| 430 |
+
|
| 431 |
+
style_range(ws, f"A{row}:I{row}")
|
| 432 |
+
ws.row_dimensions[row].height = 30
|
| 433 |
+
|
| 434 |
+
def write_attendee_row(ws, row, k1, v1, k2, v2, k3, v3, header_fill):
|
| 435 |
+
"""์ฐธ์์ ๋ช
๋จ ์ ์ฉ 3์ด ๋ถํ ๊ตฌ์กฐ (์ง์ข
| ์ด๋ฆ | ์ง์ข
| ์ด๋ฆ | ์ง์ข
| ์ด๋ฆ)"""
|
| 436 |
+
ws.cell(row, 1).value = k1
|
| 437 |
+
ws.merge_cells(start_row=row, start_column=2, end_row=row, end_column=3)
|
| 438 |
+
ws.cell(row, 2).value = v1
|
| 439 |
+
|
| 440 |
+
ws.cell(row, 4).value = k2
|
| 441 |
+
ws.merge_cells(start_row=row, start_column=5, end_row=row, end_column=6)
|
| 442 |
+
ws.cell(row, 5).value = v2
|
| 443 |
+
|
| 444 |
+
ws.cell(row, 7).value = k3
|
| 445 |
+
ws.merge_cells(start_row=row, start_column=8, end_row=row, end_column=9)
|
| 446 |
+
ws.cell(row, 8).value = v3
|
| 447 |
+
|
| 448 |
+
for c in [1, 4, 7]:
|
| 449 |
+
ws.cell(row, c).fill = header_fill
|
| 450 |
+
ws.cell(row, c).font = Font(name="Malgun Gothic", size=11, bold=True)
|
| 451 |
+
ws.cell(row, c).alignment = Alignment(horizontal="center", vertical="center", wrap_text=True)
|
| 452 |
+
|
| 453 |
+
for c in [2, 5, 8]:
|
| 454 |
+
ws.cell(row, c).font = Font(name="Malgun Gothic", size=11)
|
| 455 |
+
ws.cell(row, c).alignment = Alignment(horizontal="left", vertical="center", wrap_text=True)
|
| 456 |
+
|
| 457 |
+
style_range(ws, f"A{row}:I{row}")
|
| 458 |
+
|
| 459 |
+
# ๋ด์ฉ์ด ๊ธธ ๊ฒฝ์ฐ๋ฅผ ๋๋นํด ํ ๋์ด ์๋ ๊ณ์ฐ (๊ธ์์ ๊ธฐ๋ฐ)
|
| 460 |
+
max_len = max(len(str(v1)), len(str(v2)), len(str(v3)))
|
| 461 |
+
lines = (max_len // 18) + 1
|
| 462 |
+
ws.row_dimensions[row].height = max(30, lines * 20 + 10)
|
| 463 |
+
|
| 464 |
+
|
| 465 |
+
def write_section(ws, row, title, content, header_fill, min_height=100):
|
| 466 |
+
# ์ ๋ชฉ ํ
|
| 467 |
+
ws.merge_cells(start_row=row, start_column=1, end_row=row, end_column=9)
|
| 468 |
+
t_cell = ws.cell(row, 1)
|
| 469 |
+
t_cell.value = title
|
| 470 |
+
t_cell.font = Font(name="Malgun Gothic", size=15, bold=True)
|
| 471 |
+
t_cell.alignment = Alignment(horizontal="center", vertical="center")
|
| 472 |
+
t_cell.fill = header_fill
|
| 473 |
+
style_range(ws, f"A{row}:I{row}")
|
| 474 |
+
ws.row_dimensions[row].height = 30
|
| 475 |
+
row += 1
|
| 476 |
+
|
| 477 |
+
# ๋ด์ฉ ํ
|
| 478 |
+
ws.merge_cells(start_row=row, start_column=1, end_row=row, end_column=9)
|
| 479 |
+
c_cell = ws.cell(row, 1)
|
| 480 |
+
c_cell.value = content
|
| 481 |
+
c_cell.font = Font(name="Malgun Gothic", size=11)
|
| 482 |
+
c_cell.alignment = Alignment(horizontal="left", vertical="top", wrap_text=True)
|
| 483 |
+
style_range(ws, f"A{row}:I{row}")
|
| 484 |
+
|
| 485 |
+
# ์ค๋ฐ๊ฟ๊ณผ ํ
์คํธ ๊ธธ์ด์ ๋น๋กํด ์
๋์ด ์ ๋ฐ ๊ณ์ฐ (์๋ ํ
๋๋ฆฌ ๋ฎ์ ๋ฐฉ์ง)
|
| 486 |
+
content_str = str(content)
|
| 487 |
+
lines = 0
|
| 488 |
+
for line in content_str.split("\n"):
|
| 489 |
+
lines += (len(line) // 50) + 1
|
| 490 |
+
calculated_height = lines * 22 + 15
|
| 491 |
+
ws.row_dimensions[row].height = max(min_height, calculated_height)
|
| 492 |
+
|
| 493 |
+
return row + 1
|
| 494 |
+
|
| 495 |
+
|
| 496 |
+
def generate_excel(data):
|
| 497 |
+
wb = Workbook()
|
| 498 |
+
title_fill = PatternFill("solid", fgColor="FFEDD5")
|
| 499 |
+
header_fill = PatternFill("solid", fgColor="F3F4F6")
|
| 500 |
+
|
| 501 |
+
ws = wb.active
|
| 502 |
+
ws.title = "๊ธ์ฌ์ ๊ณต์ง์นจ๊ต์ก์ผ์ง"
|
| 503 |
+
|
| 504 |
+
ws.page_setup.paperSize = ws.PAPERSIZE_A4
|
| 505 |
+
ws.page_setup.orientation = "portrait"
|
| 506 |
+
ws.page_setup.fitToWidth = 1
|
| 507 |
+
ws.page_setup.fitToHeight = 0
|
| 508 |
+
ws.sheet_properties.pageSetUpPr.fitToPage = True
|
| 509 |
+
ws.page_margins.left = 0.3
|
| 510 |
+
ws.page_margins.right = 0.3
|
| 511 |
+
ws.page_margins.top = 0.4
|
| 512 |
+
ws.page_margins.bottom = 0.4
|
| 513 |
+
ws.sheet_view.showGridLines = False
|
| 514 |
+
|
| 515 |
+
write_title_with_approval(ws, "๊ธ์ฌ์ ๊ณต์ง์นจ ๊ต์ก์ผ์ง", title_fill, header_fill)
|
| 516 |
+
|
| 517 |
+
r = 3
|
| 518 |
+
write_info_row(ws, r, "๊ธฐ๊ด๋ช
", data["institution_name"], "๊ธฐ๊ด์ ํ", data["institution_type"], "๊ต์ก์ผ์", data["education_date"], header_fill); r += 1
|
| 519 |
+
write_info_row(ws, r, "๊ต์ก๋ช
", data["education_title"], "๊ต์ก์๊ฐ", data["education_time"], "๊ต์ก์ฅ์", data["education_place"], header_fill); r += 1
|
| 520 |
+
write_info_row(ws, r, "๊ฐ์ฌ๋ช
", data["instructor_name"], "๊ฐ์ฌ์ง์ฑ
", data["instructor_position"], "๊ต์ก๋ฐฉ๋ฒ", data["education_method"], header_fill); r += 1
|
| 521 |
+
|
| 522 |
+
r = write_section(ws, r, "๊ต์ก์ง์นจ", data["guideline_items"], header_fill, 80)
|
| 523 |
+
|
| 524 |
+
# ==== ์ฐธ์์ ๋ช
๋จ (์ง์ข
๋ณ ๋ถํ ๋ ์ด์์) ====
|
| 525 |
+
ws.merge_cells(start_row=r, start_column=1, end_row=r, end_column=9)
|
| 526 |
+
ws.cell(r, 1).value = "์ฐธ์์ ๋ช
๋จ"
|
| 527 |
+
ws.cell(r, 1).font = Font(name="Malgun Gothic", size=15, bold=True)
|
| 528 |
+
ws.cell(r, 1).alignment = Alignment(horizontal="center", vertical="center")
|
| 529 |
+
ws.cell(r, 1).fill = header_fill
|
| 530 |
+
style_range(ws, f"A{r}:I{r}")
|
| 531 |
+
ws.row_dimensions[r].height = 30
|
| 532 |
+
r += 1
|
| 533 |
+
|
| 534 |
+
att = data.get("attendees_dict", {})
|
| 535 |
+
write_attendee_row(ws, r, "์์ค์ฅ", att.get("์์ค์ฅ", ""), "์ฌํ๋ณต์ง์ฌ", att.get("์ฌํ๋ณต์ง์ฌ", ""), "๋ฌผ๋ฆฌ์น๋ฃ์ฌ", att.get("๋ฌผ๋ฆฌ์น๋ฃ์ฌ", ""), header_fill); r += 1
|
| 536 |
+
write_attendee_row(ws, r, "๊ฐํธ์กฐ๋ฌด์ฌ", att.get("๊ฐํธ์กฐ๋ฌด์ฌ", ""), "์์๋ณดํธ์ฌ", att.get("์์๋ณดํธ์ฌ", ""), "๊ธฐํ์ง์ข
", att.get("๊ธฐํ", ""), header_fill); r += 1
|
| 537 |
+
|
| 538 |
+
# =========================================
|
| 539 |
+
|
| 540 |
+
r = write_section(ws, r, "๋ฏธ์ฐธ์์ ๋ฐ ๋ณด์ถฉ๊ต์ก ๊ณํ", data["absent_staff"] or "๋ฏธ์ฐธ์์ ์์", header_fill, 70)
|
| 541 |
+
r = write_section(ws, r, "๊ต์ก๋ชฉ์ ", data["education_purpose"], header_fill, 110)
|
| 542 |
+
r = write_section(ws, r, "๊ต์ก๋ด์ฉ", data["education_content"], header_fill, 220)
|
| 543 |
+
r = write_section(ws, r, "๊ต์ก์๋ฃ ์ฒจ๋ถ/์๋ฃ๋ช
", data["education_materials"], header_fill, 80)
|
| 544 |
+
r = write_section(ws, r, "๊ต์ก๊ฒฐ๊ณผ", data["education_result"], header_fill, 120)
|
| 545 |
+
r = write_section(ws, r, "ํ์์กฐ์น ๋ฐ ํ์ฅ ์ ์ฉ๊ณํ", data["followup_plan"], header_fill, 90)
|
| 546 |
+
r = write_section(ws, r, "ํ๊ฐ ์ ํฉ๋ ์ ๊ฒ", f"{data['evaluation_score']}์ \n๋ถ์กฑ ํญ๋ชฉ: {data['missing_items']}\n{data['compliance_result']}", header_fill, 80)
|
| 547 |
+
|
| 548 |
+
# ๊ต์ก์๋ฃ ์ด๋ฏธ์ง ์ฒจ๋ถ: ์ด๋ฏธ์ง ํ์ผ์ผ ๋๋ง ์ฝ์
|
| 549 |
+
image_paths = [p for p in data.get("material_paths", []) if os.path.splitext(p)[1].lower() in [".png", ".jpg", ".jpeg"]]
|
| 550 |
+
if image_paths:
|
| 551 |
+
ws.merge_cells(start_row=r, start_column=1, end_row=r, end_column=9)
|
| 552 |
+
ws.cell(r, 1).value = "๊ต์ก์๋ฃ ์ด๋ฏธ์ง"
|
| 553 |
+
ws.cell(r, 1).font = Font(name="Malgun Gothic", size=15, bold=True)
|
| 554 |
+
ws.cell(r, 1).alignment = Alignment(horizontal="center", vertical="center")
|
| 555 |
+
ws.cell(r, 1).fill = header_fill
|
| 556 |
+
style_range(ws, f"A{r}:I{r}")
|
| 557 |
+
r += 1
|
| 558 |
+
|
| 559 |
+
anchors = ["A", "D", "G"]
|
| 560 |
+
img_row = r
|
| 561 |
+
for idx, img_path in enumerate(image_paths[:3]):
|
| 562 |
+
try:
|
| 563 |
+
img = XLImage(img_path)
|
| 564 |
+
img.width = 210
|
| 565 |
+
img.height = 150
|
| 566 |
+
ws.add_image(img, f"{anchors[idx]}{img_row}")
|
| 567 |
+
except Exception:
|
| 568 |
+
pass
|
| 569 |
+
|
| 570 |
+
# ์ด๋ฏธ์ง ์์ญ ๋ณํฉ ๋ฐ ์คํ์ผ ์ ์ฉ (ํ
๋๋ฆฌ ๋ซํ ๋ณด์ฅ)
|
| 571 |
+
ws.merge_cells(start_row=img_row, start_column=1, end_row=img_row+7, end_column=9)
|
| 572 |
+
style_range(ws, f"A{img_row}:I{img_row+7}")
|
| 573 |
+
for rr in range(img_row, img_row + 8):
|
| 574 |
+
ws.row_dimensions[rr].height = 22
|
| 575 |
+
r = img_row + 8
|
| 576 |
+
|
| 577 |
+
output = BytesIO()
|
| 578 |
+
wb.save(output)
|
| 579 |
+
output.seek(0)
|
| 580 |
+
return output
|
| 581 |
+
|
| 582 |
+
|
| 583 |
+
# -----------------------------
|
| 584 |
+
# ํ๋ฉด
|
| 585 |
+
# -----------------------------
|
| 586 |
+
menu = st.sidebar.radio("๋ฉ๋ด", ["๊ต์ก์ผ์ง ์์ฑ", "๊ต์ก๊ธฐ๋ก ๋ณด๊ธฐ"])
|
| 587 |
+
|
| 588 |
+
st.sidebar.success("DB ์ฐ๊ฒฐ")
|
| 589 |
+
st.sidebar.caption(DB_PATH)
|
| 590 |
+
|
| 591 |
+
if menu == "๊ต์ก๊ธฐ๋ก ๋ณด๊ธฐ":
|
| 592 |
+
st.subheader("๐ ์ ์ฅ๋ ๊ต์ก๊ธฐ๋ก")
|
| 593 |
+
records = load_education_records()
|
| 594 |
+
if records.empty:
|
| 595 |
+
st.info("์ ์ฅ๋ ๊ต์ก๊ธฐ๋ก์ด ์์ต๋๋ค.")
|
| 596 |
+
else:
|
| 597 |
+
st.dataframe(records, use_container_width=True)
|
| 598 |
+
|
| 599 |
+
elif menu == "๊ต์ก์ผ์ง ์์ฑ":
|
| 600 |
+
st.subheader("๐ ๊ธ์ฌ์ ๊ณต์ง์นจ ๊ต์ก์ผ์ง ์์ฑ")
|
| 601 |
+
|
| 602 |
+
col1, col2, col3 = st.columns(3)
|
| 603 |
+
institution_name = col1.text_input("๊ธฐ๊ด๋ช
", "BeeCare ์ฅ๊ธฐ์์๊ธฐ๊ด")
|
| 604 |
+
institution_type = col2.selectbox("๊ธฐ๊ด์ ํ", ["๋ฐฉ๋ฌธ์์", "๋ฐฉ๋ฌธ๋ชฉ์", "๋ฐฉ๋ฌธ๊ฐํธ", "์ฃผ๊ฐ๋ณดํธ", "์์์", "๊ณต๋์ํ๊ฐ์ "])
|
| 605 |
+
education_title = col3.text_input("๊ต์ก๋ช
", "๊ธ์ฌ์ ๊ณต์ง์นจ ์ข
์ฌ์ ๊ต์ก")
|
| 606 |
+
|
| 607 |
+
col4, col5, col6 = st.columns(3)
|
| 608 |
+
education_date = col4.date_input("๊ต์ก์ผ์", value=date.today())
|
| 609 |
+
education_time = col5.text_input("๊ต์ก์๊ฐ", "14:00~15:00")
|
| 610 |
+
education_place = col6.text_input("๊ต์ก์ฅ์", "๊ธฐ๊ด ๋ด ํ๋ก๊ทธ๋จ์ค")
|
| 611 |
+
|
| 612 |
+
col7, col8, col9 = st.columns(3)
|
| 613 |
+
instructor_name = col7.text_input("๊ฐ์ฌ๋ช
", "์์ค์ฅ")
|
| 614 |
+
instructor_position = col8.text_input("๊ฐ์ฌ์ง์ฑ
", "์์ค์ฅ")
|
| 615 |
+
education_method = col9.selectbox("๊ต์ก๋ฐฉ๋ฒ", METHODS)
|
| 616 |
+
|
| 617 |
+
selected_guidelines = st.multiselect(
|
| 618 |
+
"๊ต์ก ์ง์นจ ์ ํ",
|
| 619 |
+
list(GUIDELINES.keys()),
|
| 620 |
+
default=["02. ๋
ธ์ธ์ธ๊ถ๋ณดํธ์ง์นจ", "03. ๋
ธ์ธํ๋์๋ฐฉ์ง์นจ", "07. ๊ฐ์ผ์๋ฐฉ ๋ฐ ๊ด๋ฆฌ์ง์นจ", "09. ๋์์๋ฐฉ์ง์นจ"]
|
| 621 |
+
)
|
| 622 |
+
|
| 623 |
+
st.markdown("### ์ง์ข
๋ณ ์ฐธ์์ ๋ช
๋จ ์
๋ ฅ")
|
| 624 |
+
st.caption("๊ฐ ์นธ์ ์ฐธ์์์ ์ด๋ฆ์ ์ง์ ์ผํ๋ ๋์ด์ฐ๊ธฐ๋ก ๊ตฌ๋ถํ์ฌ ์
๋ ฅํด์ฃผ์ธ์.")
|
| 625 |
+
|
| 626 |
+
a1, a2, a3 = st.columns(3)
|
| 627 |
+
att_director = a1.text_input("์์ค์ฅ", placeholder="์: ํ๊ธธ๋")
|
| 628 |
+
att_social = a2.text_input("์ฌํ๋ณต์ง์ฌ", placeholder="์: ๊น๋ณต์ง")
|
| 629 |
+
att_therapist = a3.text_input("๋ฌผ๋ฆฌ์น๋ฃ์ฌ", placeholder="์: ์ด์น๋ฃ")
|
| 630 |
+
|
| 631 |
+
a4, a5, a6 = st.columns(3)
|
| 632 |
+
att_nurse = a4.text_input("๊ฐํธ์กฐ๋ฌด์ฌ", placeholder="์: ๋ฐ๊ฐํธ")
|
| 633 |
+
att_caregiver = a5.text_input("์์๋ณดํธ์ฌ", placeholder="์: ์ต์์, ์ ์์")
|
| 634 |
+
att_others = a6.text_input("๊ธฐํ ์ง์ข
", placeholder="์: ์กฐ๋ฆฌ์ ๊น์กฐ๋ฆฌ")
|
| 635 |
+
|
| 636 |
+
# ์
๋ ฅ๋ ๋ฐ์ดํฐ๋ฅผ ๋์
๋๋ฆฌ์ ๋ฌธ์์ด๋ก ๋ณํ
|
| 637 |
+
attendees_dict = {
|
| 638 |
+
"์์ค์ฅ": att_director,
|
| 639 |
+
"์ฌํ๋ณต์ง์ฌ": att_social,
|
| 640 |
+
"๋ฌผ๋ฆฌ์น๋ฃ์ฌ": att_therapist,
|
| 641 |
+
"๊ฐํธ์กฐ๋ฌด์ฌ": att_nurse,
|
| 642 |
+
"์์๋ณดํธ์ฌ": att_caregiver,
|
| 643 |
+
"๊ธฐํ": att_others
|
| 644 |
+
}
|
| 645 |
+
attendees_summary = "\n".join([f"[{k}] {v}" for k, v in attendees_dict.items() if v.strip()])
|
| 646 |
+
|
| 647 |
+
absent_staff = st.text_area(
|
| 648 |
+
"๋ฏธ์ฐธ์์ ๋ฐ ๋ณด์ถฉ๊ต์ก ๊ณํ",
|
| 649 |
+
placeholder="์: ๋ฐ์์๋ณดํธ์ฌ ์ฐ์ฐจ๋ก ๋ฏธ์ฐธ์, 6์ 20์ผ ๊ฐ๋ณ ๋ณด์ถฉ๊ต์ก ์์ ",
|
| 650 |
+
height=80
|
| 651 |
+
)
|
| 652 |
+
|
| 653 |
+
custom_content = st.text_area(
|
| 654 |
+
"๊ธฐ๊ด ์ถ๊ฐ ๊ต์ก๋ด์ฉ",
|
| 655 |
+
placeholder="๊ธฐ๊ด์์ ์ค์ ๋ฐ์ํ ์ ์๋ ์ฌ๋ก, ์์ฒด ์ด์๊ท์ , ์ ์์ฌํญ ๋ฑ์ ์
๋ ฅํ์ธ์.",
|
| 656 |
+
height=90
|
| 657 |
+
)
|
| 658 |
+
|
| 659 |
+
education_material_files = st.file_uploader(
|
| 660 |
+
"๊ต์ก์๋ฃ ์ฒจ๋ถ (์ด๋ฏธ์ง/PDF/๋ฌธ์ ๊ฐ๋ฅ, ์ต๋ 3๊ฐ)",
|
| 661 |
+
type=["png", "jpg", "jpeg", "pdf", "docx", "xlsx"],
|
| 662 |
+
accept_multiple_files=True
|
| 663 |
+
)
|
| 664 |
+
|
| 665 |
+
material_paths, material_names = save_uploaded_materials(education_material_files)
|
| 666 |
+
material_text = ", ".join(material_names) if material_names else "๊ธ์ฌ์ ๊ณต์ง์นจ ๊ต์ก์๋ฃ ๋น์น ๋ฐ ๊ณต๊ฐ๊ฒ์ ์๋ฃ ์ฌ์ฉ"
|
| 667 |
+
|
| 668 |
+
purpose, content = build_education_text(
|
| 669 |
+
selected_guidelines,
|
| 670 |
+
institution_type,
|
| 671 |
+
education_method,
|
| 672 |
+
custom_content
|
| 673 |
+
)
|
| 674 |
+
|
| 675 |
+
result_text = build_result_text(
|
| 676 |
+
selected_guidelines,
|
| 677 |
+
attendees_dict,
|
| 678 |
+
absent_staff,
|
| 679 |
+
education_method
|
| 680 |
+
) if selected_guidelines else ""
|
| 681 |
+
|
| 682 |
+
followup_plan = st.text_area(
|
| 683 |
+
"ํ์์กฐ์น ๋ฐ ํ์ฅ ์ ์ฉ๊ณํ",
|
| 684 |
+
value="๊ธ์ฌ์ ๊ณต์ง์นจ ๊ต์ก์๋ฃ๋ฅผ ๊ธฐ๊ด ๋ด ์ข
์ฌ์๊ฐ ํ์ธํ๊ธฐ ์ฌ์ด ์ฅ์์ ๊ณต๊ฐ ๊ฒ์ํ๊ณ , ์ข
์ฌ์๊ฐ ์์๋ก ์ง์นจ ๋ด์ฉ์ ํ์ธํ์ฌ ์ค์ ๊ธ์ฌ์ ๊ณต์ ๋ฐ์ํ๋๋ก ํ๋ค. ๊ต์ก ํ ์ข
์ฌ์๊ฐ ํ์ฅ์์ ์ง์นจ์ ์ค์ํ๋์ง ๋ชจ๋ํฐ๋งํ๊ณ , ๋ฏธ์ฐธ์์ ๋๋ ์ ๊ท์ง์์ ๋ํด์๋ ๋ณด์ถฉ๊ต์ก์ ์ค์ํ๋ค.",
|
| 685 |
+
height=100
|
| 686 |
+
)
|
| 687 |
+
|
| 688 |
+
if st.button("๐ ๊ต์ก์ผ์ง ์์ฑ", use_container_width=True):
|
| 689 |
+
data = {
|
| 690 |
+
"institution_name": institution_name,
|
| 691 |
+
"institution_type": institution_type,
|
| 692 |
+
"education_title": education_title,
|
| 693 |
+
"guideline_items": "\n".join(selected_guidelines),
|
| 694 |
+
"education_date": str(education_date),
|
| 695 |
+
"education_time": education_time,
|
| 696 |
+
"education_place": education_place,
|
| 697 |
+
"instructor_name": instructor_name,
|
| 698 |
+
"instructor_position": instructor_position,
|
| 699 |
+
"attendees_dict": attendees_dict,
|
| 700 |
+
"attendees": attendees_summary, # ํ๊ฐ ๋ก์ง ๋ฐ DB ์ ์ฅ์ฉ
|
| 701 |
+
"absent_staff": absent_staff,
|
| 702 |
+
"education_method": education_method,
|
| 703 |
+
"education_purpose": purpose,
|
| 704 |
+
"education_content": content,
|
| 705 |
+
"education_materials": material_text,
|
| 706 |
+
"education_result": result_text,
|
| 707 |
+
"followup_plan": followup_plan,
|
| 708 |
+
"material_paths": material_paths,
|
| 709 |
+
}
|
| 710 |
+
|
| 711 |
+
score, missing, compliance = evaluate_education(data)
|
| 712 |
+
data["evaluation_score"] = score
|
| 713 |
+
data["missing_items"] = ", ".join(missing) if missing else "๋ถ์กฑ ํญ๋ชฉ ์์"
|
| 714 |
+
data["compliance_result"] = compliance
|
| 715 |
+
|
| 716 |
+
st.session_state["edu_data"] = data
|
| 717 |
+
|
| 718 |
+
if "edu_data" in st.session_state:
|
| 719 |
+
data = st.session_state["edu_data"]
|
| 720 |
+
|
| 721 |
+
st.markdown("---")
|
| 722 |
+
st.subheader("์์ฑ ๊ฒฐ๊ณผ ์์ ")
|
| 723 |
+
|
| 724 |
+
data["education_purpose"] = st.text_area("๊ต์ก๋ชฉ์ ", value=data["education_purpose"], height=140)
|
| 725 |
+
data["education_content"] = st.text_area("๊ต์ก๋ด์ฉ", value=data["education_content"], height=260)
|
| 726 |
+
data["education_result"] = st.text_area("๊ต์ก๊ฒฐ๊ณผ", value=data["education_result"], height=140)
|
| 727 |
+
data["followup_plan"] = st.text_area("ํ์์กฐ์น", value=data["followup_plan"], height=100)
|
| 728 |
+
|
| 729 |
+
score, missing, compliance = evaluate_education(data)
|
| 730 |
+
data["evaluation_score"] = score
|
| 731 |
+
data["missing_items"] = ", ".join(missing) if missing else "๋ถ์กฑ ํญ๋ชฉ ์์"
|
| 732 |
+
data["compliance_result"] = compliance
|
| 733 |
+
|
| 734 |
+
st.subheader("ํ๊ฐ ์ ํฉ๋ ์ ๊ฒ")
|
| 735 |
+
e1, e2, e3 = st.columns(3)
|
| 736 |
+
e1.metric("ํ๊ฐ ์ ํฉ๋", f"{score}์ ")
|
| 737 |
+
e2.metric("๋ถ์กฑ ํญ๋ชฉ", data["missing_items"])
|
| 738 |
+
e3.metric("๊ฒฐ์ฌ๋ผ์ธ", "๋ด๋น์/์์ค์ฅ 2์นธ")
|
| 739 |
+
|
| 740 |
+
if score >= 90:
|
| 741 |
+
st.markdown(f'<div class="okbox">{compliance}</div>', unsafe_allow_html=True)
|
| 742 |
+
else:
|
| 743 |
+
st.markdown(f'<div class="warnbox">{compliance}</div>', unsafe_allow_html=True)
|
| 744 |
+
|
| 745 |
+
if st.button("๐พ ๊ต์ก๊ธฐ๋ก DB ์ ์ฅ", use_container_width=True):
|
| 746 |
+
save_education_record(data)
|
| 747 |
+
st.success("๊ต์ก๊ธฐ๋ก์ด ์ ์ฅ๋์์ต๋๋ค.")
|
| 748 |
+
|
| 749 |
+
filename = f"๊ธ์ฌ์ ๊ณต์ง์นจ๊ต์ก์ผ์ง_{data['education_date']}.xlsx"
|
| 750 |
+
st.download_button(
|
| 751 |
+
"๐ฅ ๊ธ์ฌ์ ๊ณต์ง์นจ ๊ต์ก์ผ์ง ์์
๋ค์ด๋ก๋",
|
| 752 |
+
data=generate_excel(data),
|
| 753 |
+
file_name=filename,
|
| 754 |
+
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
| 755 |
+
use_container_width=True,
|
| 756 |
+
)
|
| 757 |
+
|
| 758 |
+
st.caption("BeeCare ๊ธ์ฌ์ ๊ณต์ง์นจ ๊ต์ก์ผ์ง ์์ฑ๊ธฐ")
|