Merge branch 'feat/inout-options-popup'
This commit is contained in:
@@ -42,7 +42,7 @@ Claude Code는 이 저장소에서 작업을 시작하기 전에 **반드시 아
|
||||
|
||||
- 긴급 공지 (`app/modules/notice/`, `project_db` 마이그레이션 024 `urgent_notice*`) — 수퍼관리자만 작성(`/notice/`, ERP 왼쪽 아래·Project ⚙ 옵션). 제목·내용(이미지 bytea)·띄울 시각·전체/고른 사람 → ERP 모든 화면(`erp_base.html`·`main.html`·`admin.html` 의 `static/erp-notice.js`) 가로·세로 정가운데에 [확인] 누를 때까지(Esc·바깥 클릭 무시), 확인 기록. 연결 풀은 `ProjectStore.pool` 공유, 새 환경변수 없음. PC 알림 프로그램은 아직 미지원. 상세는 `docs/NOTICE_MODULE.md`
|
||||
|
||||
- 입출고 관리 (`app/modules/inout/`, `inout_db`, 2026-10-16) — 본사 → 공장 제품 제작 발주(발주서 `PO-YYMMDD-NN`, 제품 = `itemcode_db.single_items` 단품만, 검색 `GET /inout/api/items`·저장 때 서버 재확인), 물류 입고를 여러 번 나눠 입력, 품목별 발주·입고·미입고, 미입고 현황(제품별 합계·발주별·지연), 초과 입고는 확인 화면 후 허용(트랜잭션 안에서 발주서 잠그고 판단, `confirm_over`), 잔량 종결·취소(입고 없을 때만). 상태는 저장하지 않고 누적 입고로 계산(`store.order_status`). 권한키 `inout`(조회), **발주 담당·입고 담당·공장은 모듈 옵션**(`/inout/settings`, ERP 관리자, `inout_roles`·`inout_factories`), 관리자는 둘 다. 이카운트 "발주 대비 미입고"·Odoo 분할 입고/종결 참고. 상세 `docs/INOUT_MODULE.md`
|
||||
- 입출고 관리 (`app/modules/inout/`, `inout_db`, 2026-10-16) — 본사 → 공장 제품 제작 발주(발주서 `PO-YYMMDD-NN`, 제품 = `itemcode_db.single_items` 단품만, 검색 `GET /inout/api/items`·저장 때 서버 재확인), 물류 입고를 여러 번 나눠 입력, 품목별 발주·입고·미입고, 미입고 현황(제품별 합계·발주별·지연), 초과 입고는 확인 화면 후 허용(트랜잭션 안에서 발주서 잠그고 판단, `confirm_over`), 잔량 종결·취소(입고 없을 때만). 상태는 저장하지 않고 누적 입고로 계산(`store.order_status`). 권한키 `inout`(조회), **발주 담당·입고 담당·공장(담당자·연락처 따로, 002)은 모듈 옵션 — 상단 톱니 → 팝업**(`/inout/settings?panel=1`, ERP 관리자, `inout_roles`·`inout_factories`, 공용 `.erp-input`·`.erp-table-wrap` 겹침은 `.io` 안에서만 바로잡음), 관리자는 둘 다. 이카운트 "발주 대비 미입고"·Odoo 분할 입고/종결 참고. 상세 `docs/INOUT_MODULE.md`
|
||||
|
||||
상세는 `docs/PROJECT_OVERVIEW.md`.
|
||||
|
||||
|
||||
+26
-18
@@ -11,6 +11,7 @@ from __future__ import annotations
|
||||
from datetime import date
|
||||
from typing import Any
|
||||
|
||||
from psycopg.errors import UndefinedColumn
|
||||
from psycopg.rows import dict_row
|
||||
from psycopg_pool import ConnectionPool
|
||||
|
||||
@@ -52,27 +53,32 @@ class InoutDBStore:
|
||||
f"FROM inout_factories f {where} ORDER BY f.is_active DESC, f.sort_order, f.name"
|
||||
).fetchall()
|
||||
|
||||
def save_factory(self, *, factory_id: int | None, name: str, contact: str = "", memo: str = "",
|
||||
def save_factory(self, *, factory_id: int | None, name: str, manager: str = "", contact: str = "", memo: str = "",
|
||||
is_active: bool = True, sort_order: int = 0) -> int:
|
||||
"""공장 추가·수정. 담당자(manager, 002)·연락처(contact)는 따로."""
|
||||
name = (name or "").strip()
|
||||
if not name or len(name) > 100:
|
||||
raise ValueError("공장 이름을 1~100자로 입력하세요.")
|
||||
vals = (name, (contact or "").strip()[:200], (memo or "").strip()[:store.MEMO_MAX], bool(is_active), int(sort_order))
|
||||
with self._pool.connection() as conn:
|
||||
dup = conn.execute("SELECT id FROM inout_factories WHERE lower(name) = lower(%s) AND id <> %s",
|
||||
(name, factory_id or 0)).fetchone()
|
||||
if dup:
|
||||
raise ValueError(f"같은 이름의 공장이 이미 있습니다: {name}")
|
||||
if factory_id:
|
||||
row = conn.execute(
|
||||
"UPDATE inout_factories SET name=%s, contact=%s, memo=%s, is_active=%s, sort_order=%s "
|
||||
"WHERE id=%s RETURNING id", (*vals, factory_id)).fetchone()
|
||||
if not row:
|
||||
raise ValueError("공장을 찾을 수 없습니다.")
|
||||
return int(row["id"])
|
||||
return int(conn.execute(
|
||||
"INSERT INTO inout_factories (name, contact, memo, is_active, sort_order) VALUES (%s,%s,%s,%s,%s) RETURNING id",
|
||||
vals).fetchone()["id"])
|
||||
vals = (name, (manager or "").strip()[:100], (contact or "").strip()[:200], (memo or "").strip()[:store.MEMO_MAX],
|
||||
bool(is_active), int(sort_order))
|
||||
try:
|
||||
with self._pool.connection() as conn:
|
||||
dup = conn.execute("SELECT id FROM inout_factories WHERE lower(name) = lower(%s) AND id <> %s",
|
||||
(name, factory_id or 0)).fetchone()
|
||||
if dup:
|
||||
raise ValueError(f"같은 이름의 공장이 이미 있습니다: {name}")
|
||||
if factory_id:
|
||||
row = conn.execute(
|
||||
"UPDATE inout_factories SET name=%s, manager=%s, contact=%s, memo=%s, is_active=%s, sort_order=%s "
|
||||
"WHERE id=%s RETURNING id", (*vals, factory_id)).fetchone()
|
||||
if not row:
|
||||
raise ValueError("공장을 찾을 수 없습니다.")
|
||||
return int(row["id"])
|
||||
return int(conn.execute(
|
||||
"INSERT INTO inout_factories (name, manager, contact, memo, is_active, sort_order) "
|
||||
"VALUES (%s,%s,%s,%s,%s,%s) RETURNING id", vals).fetchone()["id"])
|
||||
except UndefinedColumn:
|
||||
raise ValueError("DB 마이그레이션 inout_db 002(공장 담당자 칸)가 아직 적용되지 않았습니다.") from None
|
||||
|
||||
def delete_factory(self, factory_id: int) -> None:
|
||||
"""발주 기록이 없는 공장만 지운다(있으면 '사용 안 함'으로 숨김)."""
|
||||
@@ -187,7 +193,9 @@ class InoutDBStore:
|
||||
def get_order(self, order_id: int) -> dict[str, Any] | None:
|
||||
with self._pool.connection() as conn:
|
||||
head = conn.execute(
|
||||
"SELECT o.*, f.name AS factory_name FROM inout_orders o JOIN inout_factories f ON f.id = o.factory_id WHERE o.id=%s",
|
||||
# 담당자(manager)는 002 열 — 미적용 DB 에서도 깨지지 않게 to_jsonb 로 읽는다
|
||||
"SELECT o.*, f.name AS factory_name, to_jsonb(f) ->> 'manager' AS factory_manager, f.contact AS factory_contact "
|
||||
"FROM inout_orders o JOIN inout_factories f ON f.id = o.factory_id WHERE o.id=%s",
|
||||
(order_id,)).fetchone()
|
||||
if not head:
|
||||
return None
|
||||
|
||||
+41
-20
@@ -8,7 +8,8 @@
|
||||
POST /inout/orders/{id}/close|reopen|cancel 종결·종결 풀기·취소(발주 담당)
|
||||
POST /inout/orders/{id}/receipts 입고 저장(입고 담당) — 발주 초과면 확인 화면, confirm_over=1 로 다시 보내야 저장
|
||||
POST /inout/orders/{id}/receipts/{rid}/delete 잘못 넣은 입고 지우기(입고 담당)
|
||||
GET|POST /inout/settings… 옵션 — 공장 목록·발주 담당·입고 담당(ERP 관리자)
|
||||
GET /inout/settings?panel=1 옵션 팝업 내용(톱니, ERP 관리자) — 공장 목록·발주 담당·입고 담당
|
||||
POST /inout/settings/… 옵션 저장 — 팝업(X-Inout-Options: 1)이면 JSON, 아니면 목록으로 이동
|
||||
GET /inout/api/items?q= 코드표 단품 검색(JSON)
|
||||
|
||||
권한: 모듈 권한키 `inout`(조회). 발주 담당·입고 담당은 옵션(inout_roles)에서 지정, ERP 관리자는 둘 다 + 옵션.
|
||||
@@ -100,6 +101,7 @@ def _render(request: Request, name: str, user: dict[str, Any], ctx: dict[str, An
|
||||
"user": user, "is_admin": perms["admin"], "perms": perms,
|
||||
"nav_items": build_erp_nav(user, active="inout"),
|
||||
"msg": request.query_params.get("msg", ""), "today": today_kst(),
|
||||
"open_options": request.query_params.get("options") == "1" and perms["admin"], # 톱니 팝업 바로 열기
|
||||
**ctx,
|
||||
}, status_code=status_code)
|
||||
|
||||
@@ -421,13 +423,7 @@ def _candidates() -> list[dict[str, str]]:
|
||||
return sorted(out, key=lambda x: x["email"])
|
||||
|
||||
|
||||
@router.get("/settings", response_class=HTMLResponse)
|
||||
def settings(request: Request) -> Any:
|
||||
got = _ctx(request)
|
||||
if not isinstance(got, tuple):
|
||||
return got
|
||||
st, user = got
|
||||
_require(st, user, "admin")
|
||||
def _options_ctx(request: Request, st: Any) -> dict[str, Any]:
|
||||
roles = st.list_roles()
|
||||
cands = _candidates()
|
||||
known = {c["email"] for c in cands}
|
||||
@@ -437,11 +433,35 @@ def settings(request: Request) -> Any:
|
||||
cands.append({"email": e, "name": "(입출고 모듈 권한 없음)"})
|
||||
known.add(e)
|
||||
reader = _items(request)
|
||||
return _render(request, "inout/settings.html", user, {
|
||||
"tab": "settings", "factories": st.list_factories(include_inactive=True), "roles": roles,
|
||||
"role_labels": store.ROLE_LABELS, "candidates": cands,
|
||||
"items_status": "연결됨" if reader is not None and reader.enabled else (reader.reason if reader else "없음"),
|
||||
})
|
||||
return {"factories": st.list_factories(include_inactive=True), "roles": roles, "role_labels": store.ROLE_LABELS,
|
||||
"candidates": cands,
|
||||
"items_status": "연결됨" if reader is not None and reader.enabled else (reader.reason if reader else "없음")}
|
||||
|
||||
|
||||
def _is_popup(request: Request) -> bool:
|
||||
"""옵션 팝업(inout.js)이 보낸 요청 — 이동 대신 JSON 으로 답하고 팝업이 제자리에서 다시 그린다."""
|
||||
return request.headers.get("x-inout-options") == "1"
|
||||
|
||||
|
||||
def _options_done(request: Request, message: str, *, ok: bool = True) -> Any:
|
||||
if _is_popup(request):
|
||||
return JSONResponse({"ok": ok, "message": message}, status_code=200 if ok else 400)
|
||||
return _redirect("/inout/?options=1", message)
|
||||
|
||||
|
||||
@router.get("/settings", response_class=HTMLResponse)
|
||||
def settings(request: Request, panel: int = 0) -> Any:
|
||||
"""옵션 — 팝업(톱니)으로 연다. panel=1 = 팝업 안 내용만, 그 밖엔 발주 목록으로 가서 팝업을 띄운다(예전 주소 호환)."""
|
||||
got = _ctx(request)
|
||||
if not isinstance(got, tuple):
|
||||
return got
|
||||
st, user = got
|
||||
_require(st, user, "admin")
|
||||
if not panel:
|
||||
return RedirectResponse(url="/inout/?options=1", status_code=303)
|
||||
from app.main import render_template # noqa: WPS433
|
||||
|
||||
return render_template(request, "inout/_options_panel.html", _options_ctx(request, st))
|
||||
|
||||
|
||||
@router.post("/settings/factories")
|
||||
@@ -454,11 +474,12 @@ async def settings_factory_save(request: Request) -> Any:
|
||||
form = await request.form()
|
||||
try:
|
||||
st.save_factory(factory_id=_opt_int(form.get("id")), name=str(form.get("name") or ""),
|
||||
contact=str(form.get("contact") or ""), memo=str(form.get("memo") or ""),
|
||||
is_active=form.get("is_active") == "1", sort_order=_opt_int(form.get("sort_order")) or 0)
|
||||
manager=str(form.get("manager") or ""), contact=str(form.get("contact") or ""),
|
||||
memo=str(form.get("memo") or ""), is_active=form.get("is_active") == "1",
|
||||
sort_order=_opt_int(form.get("sort_order")) or 0)
|
||||
except ValueError as exc:
|
||||
return _redirect("/inout/settings", str(exc))
|
||||
return _redirect("/inout/settings", "공장을 저장했습니다.")
|
||||
return _options_done(request, str(exc), ok=False)
|
||||
return _options_done(request, "공장을 저장했습니다.")
|
||||
|
||||
|
||||
@router.post("/settings/factories/{factory_id}/delete")
|
||||
@@ -471,8 +492,8 @@ def settings_factory_delete(request: Request, factory_id: int) -> Any:
|
||||
try:
|
||||
st.delete_factory(factory_id)
|
||||
except ValueError as exc:
|
||||
return _redirect("/inout/settings", str(exc))
|
||||
return _redirect("/inout/settings", "공장을 지웠습니다.")
|
||||
return _options_done(request, str(exc), ok=False)
|
||||
return _options_done(request, "공장을 지웠습니다.")
|
||||
|
||||
|
||||
@router.post("/settings/roles")
|
||||
@@ -485,7 +506,7 @@ async def settings_roles(request: Request) -> Any:
|
||||
form = await request.form()
|
||||
for role in store.ROLES:
|
||||
st.set_role_members(role, [str(e) for e in form.getlist(f"{role}_email")], by=user.get("email", ""))
|
||||
return _redirect("/inout/settings", "담당자를 저장했습니다.")
|
||||
return _options_done(request, "담당자를 저장했습니다.")
|
||||
|
||||
|
||||
# ────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
{# 입출고 관리 공용 상단: 탭(발주 목록·미입고 현황·옵션) + 새 발주서 + 알림 문구(?msg=) #}
|
||||
{# 입출고 관리 공용 상단: 탭(발주 목록·미입고 현황) + 담당 표시 + 새 발주서 + 옵션 톱니(관리자, 팝업) + 알림 문구(?msg=) #}
|
||||
<div class="io-nav">
|
||||
<a class="erp-btn {% if tab == 'orders' %}erp-btn-primary{% else %}erp-btn-outline{% endif %}" href="/inout/">발주 목록</a>
|
||||
<a class="erp-btn {% if tab == 'pending' %}erp-btn-primary{% else %}erp-btn-outline{% endif %}" href="/inout/pending">미입고 현황</a>
|
||||
{% if perms.admin %}<a class="erp-btn {% if tab == 'settings' %}erp-btn-primary{% else %}erp-btn-outline{% endif %}" href="/inout/settings">옵션</a>{% endif %}
|
||||
<span class="io-nav-gap"></span>
|
||||
<span class="io-roles erp-muted">
|
||||
{% if perms.can_order %}<span class="erp-badge erp-badge-neutral">발주 담당</span>{% endif %}
|
||||
@@ -10,5 +9,28 @@
|
||||
{% if not perms.can_order and not perms.can_receive %}조회만 가능 — 담당 지정은 옵션(관리자){% endif %}
|
||||
</span>
|
||||
{% if perms.can_order %}<a class="erp-btn erp-btn-primary" href="/inout/orders/new">+ 새 발주서</a>{% endif %}
|
||||
{% if perms.admin %}
|
||||
<button type="button" class="io-gear" id="io-options-btn" title="입출고 관리 옵션" aria-label="입출고 관리 옵션"
|
||||
aria-haspopup="dialog" {% if open_options %}data-open="1"{% endif %}>
|
||||
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
|
||||
<circle cx="12" cy="12" r="3"/>
|
||||
<path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 1 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 1 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 1 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 1 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/>
|
||||
</svg>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if msg %}<p class="io-flash" role="status">{{ msg }}</p>{% endif %}
|
||||
|
||||
{% if perms.admin %}
|
||||
{# 옵션 팝업 — 내용은 열 때 GET /inout/settings?panel=1 로 받아 넣고, 저장은 제자리에서(inout.js) #}
|
||||
<dialog class="io-dlg" id="io-options" aria-labelledby="io-options-title" tabindex="-1">
|
||||
<header class="io-dlg-head">
|
||||
<h2 id="io-options-title">입출고 관리 옵션</h2>
|
||||
<button type="button" class="io-dlg-x" data-close aria-label="닫기" title="닫기">
|
||||
<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>
|
||||
</button>
|
||||
</header>
|
||||
<p class="io-dlg-msg" role="status" hidden></p>
|
||||
<div class="io-dlg-body" id="io-options-body"><p class="erp-muted">불러오는 중…</p></div>
|
||||
</dialog>
|
||||
{% endif %}
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
{# 옵션 팝업 내용(GET /inout/settings?panel=1) — 탭: 담당자 · 공장. 폼 저장은 inout.js 가 제자리에서(X-Inout-Options: 1 → JSON).
|
||||
공장 줄은 표(<table>) 안에 폼을 둘 수 없어 입력칸에 form="…" 속성으로 표 밖 폼에 묶는다 — 열이 머리 줄과 맞는다. #}
|
||||
<div class="io-dlg-tabs" role="tablist" aria-label="옵션 분류">
|
||||
<button type="button" role="tab" class="is-active" aria-selected="true" data-pane="roles">담당자</button>
|
||||
<button type="button" role="tab" aria-selected="false" data-pane="factories" tabindex="-1">공장 <span class="io-dlg-count">{{ factories|length }}</span></button>
|
||||
</div>
|
||||
|
||||
<section class="io-dlg-pane" data-pane="roles" role="tabpanel">
|
||||
<p class="io-help">
|
||||
<b>발주 담당</b> — 발주서 작성·고치기·잔량 종결·취소. <b>입고 담당</b> — 물류에 들어온 입고 수량 입력·지우기.
|
||||
그 밖의 사람은 조회만 합니다. ERP 관리자는 지정 없이도 둘 다 할 수 있습니다.
|
||||
후보 = ERP 관리자 화면에서 <b>입출고 관리</b> 권한을 받은 사용자.
|
||||
</p>
|
||||
<form method="post" action="/inout/settings/roles" class="io-dlg-form">
|
||||
<table class="io-dlg-table">
|
||||
<thead><tr><th>사용자</th>{% for role, label in role_labels.items() %}<th class="io-c">{{ label }}</th>{% endfor %}</tr></thead>
|
||||
<tbody>
|
||||
{% for c in candidates %}
|
||||
<tr>
|
||||
<td><b class="io-user">{{ c.name or c.email }}</b><span class="io-sub">{{ c.email }}</span></td>
|
||||
{% for role in role_labels %}
|
||||
<td class="io-c"><input type="checkbox" name="{{ role }}_email" value="{{ c.email }}" {% if c.email in roles[role] %}checked{% endif %}
|
||||
aria-label="{{ c.email }} {{ role_labels[role] }}" /></td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr><td colspan="3" class="io-empty">입출고 관리 권한을 받은 사용자가 없습니다 — ERP 관리자 화면에서 먼저 권한을 주세요.</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="io-dlg-actions"><button type="submit" class="erp-btn erp-btn-primary">담당자 저장</button></div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<section class="io-dlg-pane" data-pane="factories" role="tabpanel" hidden>
|
||||
<p class="io-help">발주서에서 고르는 공장(발주처)입니다. 발주 기록이 있는 공장은 지우지 말고 <b>사용</b>을 끄면 목록에서 숨겨집니다.</p>
|
||||
{% for f in factories %}<form method="post" action="/inout/settings/factories" id="io-f{{ f.id }}" class="io-dlg-form"><input type="hidden" name="id" value="{{ f.id }}" /></form>{% endfor %}
|
||||
<form method="post" action="/inout/settings/factories" id="io-fnew" class="io-dlg-form"><input type="hidden" name="is_active" value="1" /></form>
|
||||
<table class="io-dlg-table io-factory-table">
|
||||
<colgroup><col class="w-name" /><col class="w-man" /><col class="w-tel" /><col class="w-memo" /><col class="w-sort" /><col class="w-use" /><col class="w-cnt" /><col class="w-btn" /></colgroup>
|
||||
<thead><tr><th>공장 이름</th><th>담당자</th><th>연락처</th><th>메모</th><th class="io-c">순서</th><th class="io-c">사용</th><th class="io-c">발주</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
{% for f in factories %}
|
||||
{% set fid = 'io-f' ~ f.id %}
|
||||
<tr class="{% if not f.is_active %}is-inactive{% endif %}">
|
||||
<td><input class="io-in" form="{{ fid }}" type="text" name="name" value="{{ f.name }}" maxlength="100" required aria-label="공장 이름" /></td>
|
||||
<td><input class="io-in" form="{{ fid }}" type="text" name="manager" value="{{ f.manager }}" maxlength="100" aria-label="담당자" /></td>
|
||||
<td><input class="io-in" form="{{ fid }}" type="tel" name="contact" value="{{ f.contact }}" maxlength="200" aria-label="연락처" /></td>
|
||||
<td><input class="io-in" form="{{ fid }}" type="text" name="memo" value="{{ f.memo }}" maxlength="500" aria-label="메모" /></td>
|
||||
<td class="io-c"><input class="io-in io-in-num" form="{{ fid }}" type="number" name="sort_order" value="{{ f.sort_order }}" aria-label="순서" /></td>
|
||||
<td class="io-c"><input form="{{ fid }}" type="checkbox" name="is_active" value="1" {% if f.is_active %}checked{% endif %} aria-label="사용" /></td>
|
||||
<td class="io-c io-sub">{{ f.order_count }}건</td>
|
||||
<td class="io-btns">
|
||||
<button form="{{ fid }}" type="submit" class="erp-btn erp-btn-outline erp-btn-sm">저장</button>
|
||||
{% if not f.order_count %}<button form="{{ fid }}" type="submit" class="erp-btn erp-btn-outline erp-btn-sm" formaction="/inout/settings/factories/{{ f.id }}/delete"
|
||||
formnovalidate data-confirm="공장 '{{ f.name }}' 을(를) 지울까요?">지우기</button>{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr class="io-new-row">
|
||||
<td><input class="io-in" form="io-fnew" type="text" name="name" maxlength="100" required placeholder="새 공장 이름" aria-label="새 공장 이름" /></td>
|
||||
<td><input class="io-in" form="io-fnew" type="text" name="manager" maxlength="100" placeholder="담당자" aria-label="담당자" /></td>
|
||||
<td><input class="io-in" form="io-fnew" type="tel" name="contact" maxlength="200" placeholder="010-0000-0000" aria-label="연락처" /></td>
|
||||
<td><input class="io-in" form="io-fnew" type="text" name="memo" maxlength="500" placeholder="메모" aria-label="메모" /></td>
|
||||
<td class="io-c"><input class="io-in io-in-num" form="io-fnew" type="number" name="sort_order" value="0" aria-label="순서" /></td>
|
||||
<td></td><td></td>
|
||||
<td class="io-btns"><button form="io-fnew" type="submit" class="erp-btn erp-btn-primary erp-btn-sm">+ 추가</button></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
<p class="io-dlg-foot">코드표(단품) 연결: {{ items_status }}</p>
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends "erp_base.html" %}
|
||||
{% from "inout/_macros.html" import status_badge, progress, due, n %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016a" />{% endblock %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016b" />{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="io">
|
||||
@@ -58,4 +58,4 @@
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261016a" defer></script>{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261016b" defer></script>{% endblock %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends "erp_base.html" %}
|
||||
{% from "inout/_macros.html" import status_badge, progress, due, n %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016a" />{% endblock %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016b" />{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% set active = order.status in ('open', 'partial') %}
|
||||
@@ -14,7 +14,7 @@
|
||||
<h2>{{ order.order_no }}</h2>{{ status_badge(order.status, order.status_label) }}
|
||||
</div>
|
||||
<dl class="io-head-meta">
|
||||
<div><dt>공장</dt><dd>{{ order.factory_name }}</dd></div>
|
||||
<div><dt>공장</dt><dd>{{ order.factory_name }}{% if order.factory_manager or order.factory_contact %}<span class="io-factory-who">{{ order.factory_manager }}{% if order.factory_manager and order.factory_contact %} · {% endif %}{{ order.factory_contact }}</span>{% endif %}</dd></div>
|
||||
<div><dt>발주일</dt><dd>{{ order.order_date.strftime('%Y-%m-%d') }}</dd></div>
|
||||
<div><dt>입고 예정일</dt><dd>{{ due(order.due_date, today, active) }}</dd></div>
|
||||
<div><dt>진행</dt><dd>{{ progress(order.summary) }}</dd></div>
|
||||
@@ -130,4 +130,4 @@
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261016a" defer></script>{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261016b" defer></script>{% endblock %}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{% extends "erp_base.html" %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016a" />{% endblock %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016b" />{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="io">
|
||||
@@ -76,4 +76,4 @@
|
||||
</form>
|
||||
</section>
|
||||
{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261016a" defer></script>{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261016b" defer></script>{% endblock %}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{% extends "erp_base.html" %}
|
||||
{% from "inout/_macros.html" import due, n %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016a" />{% endblock %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016b" />{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="io">
|
||||
@@ -88,4 +88,4 @@
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261016a" defer></script>{% endblock %}
|
||||
{% block scripts %}<script src="/static/inout.js?v=20261016b" defer></script>{% endblock %}
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
{% extends "erp_base.html" %}
|
||||
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016a" />{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<section class="io">
|
||||
{% include "inout/_nav.html" %}
|
||||
|
||||
<div class="io-settings">
|
||||
<form method="post" action="/inout/settings/roles" class="erp-card-block io-block">
|
||||
<div class="erp-card-block-head"><h2>담당자</h2><span class="erp-muted">ERP 관리자는 지정 없이도 둘 다 할 수 있습니다</span></div>
|
||||
<p class="io-help">
|
||||
<b>발주 담당</b> — 발주서 작성·고치기·잔량 종결·취소. <b>입고 담당</b> — 물류에 들어온 입고 수량 입력·지우기.
|
||||
그 밖의 사람은 조회만 합니다. 후보 = ERP 관리자 화면에서 <b>입출고 관리</b> 권한을 받은 사용자.
|
||||
</p>
|
||||
<div class="erp-table-wrap">
|
||||
<table class="erp-table io-table">
|
||||
<thead><tr><th>사용자</th>{% for role, label in role_labels.items() %}<th class="io-col-check">{{ label }}</th>{% endfor %}</tr></thead>
|
||||
<tbody>
|
||||
{% for c in candidates %}
|
||||
<tr>
|
||||
<td>{{ c.name or c.email }}<div class="erp-row-sub">{{ c.email }}</div></td>
|
||||
{% for role in role_labels %}
|
||||
<td class="io-col-check"><input type="checkbox" name="{{ role }}_email" value="{{ c.email }}" {% if c.email in roles[role] %}checked{% endif %}
|
||||
aria-label="{{ c.email }} {{ role_labels[role] }}" /></td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr><td colspan="3" class="erp-empty">입출고 관리 권한을 받은 사용자가 없습니다 — ERP 관리자 화면에서 먼저 권한을 주세요.</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="io-form-actions"><button type="submit" class="erp-btn erp-btn-primary">담당자 저장</button></div>
|
||||
</form>
|
||||
|
||||
<div class="erp-card-block io-block">
|
||||
<div class="erp-card-block-head"><h2>공장(발주처)</h2><span class="erp-muted">발주 기록이 있는 공장은 지우지 말고 '사용 안 함'으로</span></div>
|
||||
{# 줄마다 폼 하나(표 안에 폼을 넣을 수 없어 격자로) — 머리 줄과 같은 열 #}
|
||||
<div class="io-factories" role="table" aria-label="공장 목록">
|
||||
<div class="io-factory-row io-factory-head" role="row">
|
||||
<span>이름</span><span>담당자·연락처</span><span>메모</span><span>순서</span><span>사용</span><span>발주</span><span></span>
|
||||
</div>
|
||||
{% for f in factories %}
|
||||
<form method="post" action="/inout/settings/factories" class="io-factory-row{% if not f.is_active %} io-inactive{% endif %}" role="row">
|
||||
<input type="hidden" name="id" value="{{ f.id }}" />
|
||||
<input class="erp-input" type="text" name="name" value="{{ f.name }}" maxlength="100" required aria-label="공장 이름" />
|
||||
<input class="erp-input" type="text" name="contact" value="{{ f.contact }}" maxlength="200" aria-label="담당자·연락처" />
|
||||
<input class="erp-input" type="text" name="memo" value="{{ f.memo }}" maxlength="500" aria-label="메모" />
|
||||
<input class="erp-input" type="number" name="sort_order" value="{{ f.sort_order }}" aria-label="순서" />
|
||||
<label class="io-check"><input type="checkbox" name="is_active" value="1" {% if f.is_active %}checked{% endif %} aria-label="사용" /></label>
|
||||
<span class="erp-muted">{{ f.order_count }}건</span>
|
||||
<span class="io-factory-btns">
|
||||
<button type="submit" class="erp-btn erp-btn-outline erp-btn-sm">저장</button>
|
||||
{% if not f.order_count %}<button type="submit" class="erp-btn erp-btn-outline erp-btn-sm" formaction="/inout/settings/factories/{{ f.id }}/delete"
|
||||
formnovalidate data-erp-confirm-btn="공장 '{{ f.name }}' 을(를) 지울까요?">지우기</button>{% endif %}
|
||||
</span>
|
||||
</form>
|
||||
{% endfor %}
|
||||
<form method="post" action="/inout/settings/factories" class="io-factory-row io-new-factory" role="row">
|
||||
<input class="erp-input" type="text" name="name" maxlength="100" required placeholder="새 공장 이름" aria-label="새 공장 이름" />
|
||||
<input class="erp-input" type="text" name="contact" maxlength="200" placeholder="담당자·연락처" aria-label="담당자·연락처" />
|
||||
<input class="erp-input" type="text" name="memo" maxlength="500" placeholder="메모" aria-label="메모" />
|
||||
<input class="erp-input" type="number" name="sort_order" value="0" aria-label="순서" />
|
||||
<input type="hidden" name="is_active" value="1" />
|
||||
<span></span><span></span>
|
||||
<span class="io-factory-btns"><button type="submit" class="erp-btn erp-btn-primary erp-btn-sm">+ 공장 추가</button></span>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="erp-muted io-foot">코드표(단품) 연결: {{ items_status }}</p>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
+70
-17
@@ -14,8 +14,8 @@
|
||||
|
||||
/* 거르기 줄 */
|
||||
.io-filter { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
||||
.io-filter .erp-input, .io-filter .erp-select { width: auto; }
|
||||
.io-search { min-width: 220px; }
|
||||
.io-filter .erp-select { width: auto; }
|
||||
.io-search { width: 260px; }
|
||||
.io-filter input[type="date"] { width: 150px; }
|
||||
.io-date { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--color-midtone-gray); }
|
||||
.io-seg { display: inline-flex; padding: 2px; border: 1px solid var(--color-subtle-ash); border-radius: 10px; background: #fff; }
|
||||
@@ -69,7 +69,7 @@
|
||||
.io-kpis-head { grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); align-self: start; min-width: 320px; }
|
||||
.io-head-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 12px; border-top: 1px solid var(--color-subtle-ash); }
|
||||
.io-head-actions form { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
|
||||
.io-close-reason { width: 200px; }
|
||||
.io-close-reason { width: 220px; }
|
||||
|
||||
/* 입고 입력 */
|
||||
.io-col-no { width: 36px; color: var(--color-midtone-gray); }
|
||||
@@ -87,6 +87,7 @@
|
||||
/* 발주서 폼 */
|
||||
.io-order-form { overflow: visible; }
|
||||
.io-lines .io-col-qty { width: 130px; }
|
||||
.io-lines .erp-input { width: 100%; }
|
||||
.io-lines .io-col-del { width: 48px; text-align: center; }
|
||||
.io-lines tfoot td { padding: 10px 16px; border-top: 1px solid var(--color-subtle-ash); }
|
||||
.io-item-cell { position: relative; min-width: 320px; }
|
||||
@@ -102,23 +103,75 @@
|
||||
.io-suggest-item:hover, .io-suggest-item.is-active { background: #eef6ff; }
|
||||
.io-suggest-empty { padding: 10px 12px; font-size: 12.5px; color: var(--color-midtone-gray); white-space: normal; }
|
||||
|
||||
/* 옵션 */
|
||||
.io-settings { display: flex; flex-direction: column; gap: 14px; }
|
||||
.io-col-check { width: 90px; text-align: center !important; }
|
||||
.io-factories { padding: 6px 12px 12px; }
|
||||
.io-factory-row { display: grid; grid-template-columns: minmax(140px, 1.2fr) minmax(140px, 1.2fr) minmax(120px, 1.5fr) 70px 50px 60px auto;
|
||||
gap: 8px; align-items: center; padding: 6px 8px; margin: 0; border-bottom: 1px solid var(--color-subtle-ash); }
|
||||
.io-factory-head { font-size: 12px; color: var(--color-midtone-gray); font-weight: 500; }
|
||||
.io-factory-row .erp-input { width: 100%; min-width: 0; }
|
||||
.io-factory-row.io-inactive .erp-input { color: var(--color-midtone-gray); background: var(--color-ghost-gray); }
|
||||
.io-new-factory { border-bottom: 0; background: #fafbfc; border-radius: 8px; }
|
||||
.io-factory-btns { display: inline-flex; gap: 6px; justify-content: flex-end; }
|
||||
.io-check { display: inline-flex; justify-content: center; }
|
||||
/* ── 공용 ERP 스타일과 겹치는 부분(2026-10-16 옵션 화면 겹침) ──
|
||||
· .erp-input 은 min-width 240px + content-box 라 좁은 칸에서 옆 칸을 덮는다 → 이 모듈 안에서는 테두리 기준·최소폭 없음
|
||||
· .erp-table-wrap 은 카드 모양(그림자·둥근 모서리)이라 카드 안에 넣으면 상자가 겹쳐 보인다 → 카드 안에서는 평평하게 */
|
||||
.io *, .io *::before, .io *::after, .io-dlg *, .io-dlg *::before, .io-dlg *::after { box-sizing: border-box; }
|
||||
.io .erp-input { min-width: 0; }
|
||||
.io .erp-card-block .erp-table-wrap { border-radius: 0; box-shadow: none; background: transparent; }
|
||||
|
||||
/* 옵션 톱니(관리자) — 실적 설정 톱니처럼 둥근 아이콘 단추 */
|
||||
.io-gear { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; padding: 0;
|
||||
border: 1px solid var(--color-subtle-ash); border-radius: 50%; background: #fff; color: #525860; cursor: pointer;
|
||||
transition: background .12s, color .12s, border-color .12s; }
|
||||
.io-gear:hover { background: var(--color-ghost-gray); color: var(--color-rich-black); border-color: #c9ccd1; }
|
||||
.io-gear:focus-visible { outline: 2px solid var(--color-rich-black); outline-offset: 2px; }
|
||||
.io-factory-who { display: block; font-size: 12px; color: var(--color-midtone-gray); margin-top: 2px; }
|
||||
|
||||
/* 옵션 팝업 */
|
||||
.io-dlg { width: min(1040px, calc(100vw - 40px)); max-height: min(760px, calc(100vh - 40px)); padding: 0; border: 1px solid var(--color-subtle-ash);
|
||||
border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .2); color: var(--color-rich-black); overflow: hidden; }
|
||||
.io-dlg[open] { display: flex; flex-direction: column; }
|
||||
.io-dlg:focus { outline: none; }
|
||||
.io-dlg-tabs button:focus-visible { outline: 2px solid var(--color-rich-black); outline-offset: -4px; border-radius: 6px; }
|
||||
.io-dlg::backdrop { background: rgba(0, 0, 0, .35); }
|
||||
.io-dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 14px 22px; border-bottom: 1px solid var(--color-subtle-ash); }
|
||||
.io-dlg-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
|
||||
.io-dlg-x { display: inline-flex; padding: 6px; border: 0; border-radius: 6px; background: none; color: #6d6e6f; cursor: pointer; }
|
||||
.io-dlg-x:hover { background: var(--color-ghost-gray); color: var(--color-rich-black); }
|
||||
.io-dlg-msg { margin: 12px 22px 0; padding: 9px 12px; border-radius: 8px; background: #e6f8e9; color: #1e7a34; border: 1px solid #c2efc8; font-size: 13px; }
|
||||
.io-dlg-msg.is-bad { background: #fbe9e6; color: #a1261b; border-color: #efc6bf; }
|
||||
.io-dlg-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 14px 22px 18px; }
|
||||
.io-dlg-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--color-subtle-ash); margin-bottom: 14px; }
|
||||
.io-dlg-tabs button { padding: 8px 14px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none;
|
||||
font: inherit; font-size: 14px; color: var(--color-midtone-gray); cursor: pointer; }
|
||||
.io-dlg-tabs button:hover { color: var(--color-rich-black); }
|
||||
.io-dlg-tabs button.is-active { color: var(--color-rich-black); font-weight: 600; border-bottom-color: var(--color-rich-black); }
|
||||
.io-dlg-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--color-ghost-gray); font-size: 11px; text-align: center; }
|
||||
.io-dlg-body .io-help { padding: 0 0 12px; }
|
||||
.io-dlg-form { margin: 0; }
|
||||
.io-dlg-table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
|
||||
.io-dlg-table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--color-midtone-gray); padding: 8px 6px; border-bottom: 1px solid var(--color-subtle-ash); white-space: nowrap; }
|
||||
.io-dlg-table td { padding: 7px 6px; border-bottom: 1px solid var(--color-subtle-ash); vertical-align: middle; }
|
||||
.io-dlg-table tbody tr:last-child td { border-bottom: 0; }
|
||||
.io-dlg-table .io-c { text-align: center; }
|
||||
.io-dlg-table td.io-c input[type="checkbox"] { width: 16px; height: 16px; }
|
||||
.io-user { display: block; font-weight: 500; }
|
||||
.io-sub { font-size: 12px; color: var(--color-midtone-gray); }
|
||||
.io-empty { text-align: center; padding: 18px; color: var(--color-midtone-gray); }
|
||||
.io-in { width: 100%; min-width: 0; padding: 6px 9px; border: 1px solid var(--color-subtle-ash); border-radius: 6px; font: inherit; font-size: 13px;
|
||||
color: var(--color-rich-black); background: #fff; }
|
||||
.io-in:focus { outline: none; border-color: var(--color-rich-black); box-shadow: 0 0 0 3px rgba(0, 0, 0, .06); }
|
||||
.io-in-num { text-align: right; }
|
||||
.io-factory-table col.w-name { width: 18%; }
|
||||
.io-factory-table col.w-man { width: 12%; }
|
||||
.io-factory-table col.w-tel { width: 18%; }
|
||||
.io-factory-table col.w-memo { width: auto; }
|
||||
.io-factory-table col.w-sort { width: 64px; }
|
||||
.io-factory-table col.w-use { width: 48px; }
|
||||
.io-factory-table col.w-cnt { width: 52px; }
|
||||
.io-factory-table col.w-btn { width: 128px; }
|
||||
.io-factory-table tr.is-inactive .io-in { background: var(--color-ghost-gray); color: var(--color-midtone-gray); }
|
||||
.io-factory-table .io-new-row td { background: #fafbfc; border-top: 1px solid var(--color-subtle-ash); }
|
||||
.io-btns { text-align: right; white-space: nowrap; } /* td 에 flex 를 주면 표 칸이 깨진다(줄 선·배경 어긋남) */
|
||||
.io-btns .erp-btn + .erp-btn { margin-left: 4px; }
|
||||
.io-dlg-actions { display: flex; justify-content: flex-end; padding-top: 12px; }
|
||||
.io-dlg-foot { margin: 14px 0 0; font-size: 12px; color: var(--color-midtone-gray); }
|
||||
|
||||
@media (max-width: 900px) {
|
||||
.io-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
.io-head { grid-template-columns: 1fr; }
|
||||
.io-kpis-head { min-width: 0; }
|
||||
.io-factory-row { grid-template-columns: 1fr 1fr; }
|
||||
.io-factory-head { display: none; }
|
||||
.io-dlg-body { overflow-x: auto; }
|
||||
.io-factory-table { min-width: 860px; }
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
· 목록 줄 누르기 = 발주서로
|
||||
· 발주서 폼: 제품 줄 추가·지우기·번호·합계, 코드표 단품 검색(GET /inout/api/items?q=) 드롭다운
|
||||
· 발주서 화면: [남은 수량 모두 채우기], 이번 입고 합계
|
||||
· 옵션 팝업(톱니): 담당자·공장 — 열 때 내용을 받고, 저장은 제자리
|
||||
· data-erp-confirm-btn: 버튼별 확인(formaction 이 있는 버튼 — 공용 data-erp-confirm 은 form.submit() 이라 누른 버튼이 사라짐) */
|
||||
(function () {
|
||||
"use strict";
|
||||
@@ -224,4 +225,86 @@
|
||||
});
|
||||
paintTotal();
|
||||
}
|
||||
|
||||
// ── 옵션 팝업(톱니, 관리자) — 내용은 GET /inout/settings?panel=1, 저장은 제자리(X-Inout-Options: 1 → JSON) ──
|
||||
const optBtn = document.getElementById("io-options-btn");
|
||||
const optDlg = document.getElementById("io-options");
|
||||
if (optBtn && optDlg) initOptions(optBtn, optDlg);
|
||||
|
||||
function initOptions(btn, dlg) {
|
||||
const body = dlg.querySelector("#io-options-body");
|
||||
const msgEl = dlg.querySelector(".io-dlg-msg");
|
||||
let changed = false, pane = "roles";
|
||||
|
||||
function say(text, bad) {
|
||||
msgEl.textContent = text || "";
|
||||
msgEl.hidden = !text;
|
||||
msgEl.classList.toggle("is-bad", !!bad);
|
||||
}
|
||||
function showPane(name) {
|
||||
pane = name;
|
||||
body.querySelectorAll(".io-dlg-tabs [data-pane]").forEach(function (t) {
|
||||
const on = t.dataset.pane === name;
|
||||
t.classList.toggle("is-active", on);
|
||||
t.setAttribute("aria-selected", on ? "true" : "false");
|
||||
t.tabIndex = on ? 0 : -1;
|
||||
});
|
||||
body.querySelectorAll(".io-dlg-pane").forEach(function (p) { p.hidden = p.dataset.pane !== name; });
|
||||
}
|
||||
async function load() {
|
||||
const res = await fetch("/inout/settings?panel=1", { headers: { "X-Inout-Options": "1" } });
|
||||
if (!res.ok) throw new Error("HTTP " + res.status);
|
||||
body.innerHTML = await res.text();
|
||||
showPane(pane);
|
||||
}
|
||||
async function open() {
|
||||
say("");
|
||||
if (!dlg.open) dlg.showModal();
|
||||
try {
|
||||
await load();
|
||||
dlg.focus({ preventScroll: true }); // 닫기(✕)에 초점 테두리가 생기지 않게 창 자체에(Tab 으로 안으로 이동)
|
||||
} catch (_) {
|
||||
body.innerHTML = '<p class="io-error">옵션을 불러오지 못했습니다. 잠시 뒤 다시 여세요.</p>';
|
||||
}
|
||||
}
|
||||
btn.addEventListener("click", open);
|
||||
dlg.addEventListener("click", function (e) {
|
||||
if (e.target.closest("[data-close]")) { dlg.close(); return; }
|
||||
const tab = e.target.closest(".io-dlg-tabs [data-pane]");
|
||||
if (tab) showPane(tab.dataset.pane);
|
||||
});
|
||||
dlg.addEventListener("close", function () {
|
||||
const url = new URL(location.href);
|
||||
const hadParam = url.searchParams.has("options");
|
||||
url.searchParams.delete("options");
|
||||
url.searchParams.delete("msg");
|
||||
if (changed) location.href = url.toString(); // 담당 표시·공장 목록이 바뀌었을 수 있다
|
||||
else if (hadParam) history.replaceState(null, "", url.toString());
|
||||
});
|
||||
dlg.addEventListener("submit", async function (e) {
|
||||
const form = e.target;
|
||||
if (!form.classList || !form.classList.contains("io-dlg-form")) return;
|
||||
e.preventDefault();
|
||||
const sub = e.submitter;
|
||||
if (sub && sub.dataset.confirm && !(await confirmMsg(sub.dataset.confirm))) return;
|
||||
const action = sub && sub.getAttribute("formaction") ? sub.getAttribute("formaction") : form.getAttribute("action");
|
||||
const buttons = Array.from(dlg.querySelectorAll("button[type=submit]"));
|
||||
buttons.forEach(function (b) { b.disabled = true; });
|
||||
try {
|
||||
const res = await fetch(action, { method: "POST", headers: { "X-Inout-Options": "1" },
|
||||
body: new URLSearchParams(new FormData(form)) });
|
||||
let data = {};
|
||||
try { data = await res.json(); } catch (_) {}
|
||||
if (!res.ok || data.ok === false) { say(data.message || data.detail || "저장하지 못했습니다.", true); return; }
|
||||
changed = true;
|
||||
await load();
|
||||
say(data.message || "저장했습니다.");
|
||||
} catch (_) {
|
||||
say("저장하지 못했습니다(연결 오류). 다시 눌러 주세요.", true);
|
||||
} finally {
|
||||
buttons.forEach(function (b) { if (b.isConnected) b.disabled = false; });
|
||||
}
|
||||
});
|
||||
if (btn.dataset.open === "1") open();
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -287,6 +287,18 @@ curl -s http://127.0.0.1:8080/inout/health # {"status":"ok"} — DSN
|
||||
그다음 ERP 관리자 화면에서 쓸 사람에게 **입출고 관리** 권한 → 입출고 관리 → 옵션에서 공장·발주 담당·입고 담당 지정.
|
||||
백업: 매일 `docker exec postgres-db pg_dump -U postgres inout_db > /var/backups/postgres/inout_db_$(date +%F).sql`.
|
||||
|
||||
## 입출고 관리 공장 담당자 마이그레이션 (inout_db 002)
|
||||
|
||||
002는 `inout_factories.manager`(담당자) 열만 추가한다(다시 실행 가능). 예전 "담당자·연락처" 한 칸에 숫자 없이 이름만 있던 값은 담당자로 옮긴다.
|
||||
미적용이면 공장 저장만 안내(발주·입고는 그대로).
|
||||
|
||||
```bash
|
||||
cd /opt/www/main
|
||||
docker exec postgres-db pg_dump -U postgres inout_db > ~/inout_db_before_002_$(date +%Y%m%d%H%M).sql
|
||||
docker exec -i postgres-db psql -v ON_ERROR_STOP=1 -U postgres -d inout_db < scripts/sql/inout_db_002_factory_manager.sql
|
||||
docker exec postgres-db psql -U postgres -d inout_db -c "SELECT name, manager, contact FROM inout_factories ORDER BY id;"
|
||||
```
|
||||
|
||||
## 긴급 공지 마이그레이션 (024)
|
||||
|
||||
024는 `urgent_notices`·`urgent_notice_targets`·`urgent_notice_acks`·`urgent_notice_images` 테이블만 추가한다(기존 값 그대로, 다시 실행 가능).
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
| 모듈 권한 `inout` | 발주 목록·발주서·미입고 현황 조회 |
|
||||
| **발주 담당**(옵션에서 지정) | 발주서 작성·고치기·잔량 종결/풀기·취소 |
|
||||
| **입고 담당**(옵션에서 지정) | 입고 수량 입력·입고 기록 지우기 |
|
||||
| ERP 관리자(`role=admin`) | 위 전부 + **옵션**(공장 목록·담당자) |
|
||||
| ERP 관리자(`role=admin`) | 위 전부 + **옵션**(공장 목록·담당자) — 상단 오른쪽 **톱니** → 팝업 |
|
||||
|
||||
담당자 후보 = ERP 관리자 화면에서 `inout` 권한을 받은 사용자. 권한이 빠졌는데 담당으로 남은 사람도 옵션에 보여서 뺄 수 있다.
|
||||
담당은 `inout_roles(email, role)` — role `order`(발주)·`receive`(입고).
|
||||
@@ -58,23 +58,28 @@ cupang·malaysia 와 같은 DSN). 화면에서 코드·이름으로 검색(`GET
|
||||
| `/inout/pending` | 미입고 현황 — 요약 숫자, 제품별 합계, 발주별, 초과 입고 |
|
||||
| `/inout/orders/new`, `/{id}/edit` | 발주서 폼 — 공장·발주일·입고 예정일·메모, 제품 줄(검색 드롭다운·수량·줄 메모), 합계 |
|
||||
| `/inout/orders/{id}` | 발주서 — 품목별 발주·입고·미입고·상태, **이번 입고** 칸(입고 담당) + [남은 수량 모두 채우기], 입고 기록, 종결·취소 |
|
||||
| `/inout/settings` | 옵션(관리자) — 담당자(발주·입고 체크), 공장(이름·연락처·메모·순서·사용, 발주 기록 없을 때만 지우기) |
|
||||
| 톱니 → 옵션 팝업 | 관리자만. 탭 **담당자**(발주·입고 체크) · **공장**(이름·담당자·연락처·메모·순서·사용, 발주 기록 없을 때만 지우기). 내용은 `GET /inout/settings?panel=1`, 저장은 팝업 안에서(`X-Inout-Options: 1` → JSON, 같은 탭 그대로 다시 그림), 바뀐 게 있으면 닫을 때 화면 새로고침. 예전 주소 `/inout/settings` = 목록으로 가서 팝업(`?options=1`) |
|
||||
|
||||
화면은 서버 폼(POST → 303 + `?msg=` 안내). `static/inout.js` 는 입력 보조만(제품 검색 드롭다운 — `position: fixed` 로 body 에 붙여
|
||||
표 가로 스크롤에 잘리지 않음, 줄 추가·삭제·합계, 남은 수량 채우기, 버튼별 확인 `data-erp-confirm-btn`).
|
||||
공용 `.erp-page` 가 content-box 라 넓은 표에서 48px 넘치므로 이 화면만 `.erp-page:has(> .io) { box-sizing: border-box }`.
|
||||
공용 스타일과 겹치는 것 — 이 모듈 안에서만 바로잡는다(공용 파일은 그대로):
|
||||
`.erp-page` 가 content-box 라 넓은 표에서 48px 넘침 → `.erp-page:has(> .io) { box-sizing: border-box }`;
|
||||
`.erp-input` 이 min-width 240px + content-box 라 좁은 칸에서 옆 칸을 덮음, `.erp-table-wrap` 이 카드 모양(그림자·둥근 모서리)이라 카드 안에서 상자가 겹쳐 보임
|
||||
→ `.io`·`.io-dlg` 안은 border-box·최소폭 없음·카드 안 표는 평평하게(2026-10-16 옵션 화면 겹침). 공장 표는 진짜 `<table>` + 입력칸 `form="…"` 속성(줄마다 표 밖 폼)으로 열을 맞춘다.
|
||||
|
||||
## 6. DB (`inout_db`, `scripts/sql/inout_db_init.sql`)
|
||||
|
||||
| 표 | 내용 |
|
||||
|---|---|
|
||||
| `inout_factories` | 공장 — 이름(대소문자 무시 유일)·연락처·메모·사용·순서 |
|
||||
| `inout_factories` | 공장 — 이름(대소문자 무시 유일)·담당자(`manager`, 002)·연락처(`contact`)·메모·사용·순서 |
|
||||
| `inout_roles` | 담당자 — (email, role: order/receive) |
|
||||
| `inout_orders` | 발주서 — 번호·공장·발주일·입고 예정일·메모·종결(시각·사람·사유)·취소 |
|
||||
| `inout_order_lines` | 발주 품목 — 단품 코드·이름 사본·수량·줄 메모, 발주서 안에서 코드 유일 |
|
||||
| `inout_receipts` | 입고 1건(한 번 들어온 것) — 입고일·메모·입력자 |
|
||||
| `inout_receipt_lines` | 입고 품목별 수량 |
|
||||
|
||||
마이그레이션 `inout_db_002_factory_manager.sql`(2026-10-16): `manager` 열 추가, 예전 한 칸에 숫자 없이 이름만 있던 값은 담당자로 옮김(숫자가 있으면 연락처로 둠).
|
||||
002 미적용이어도 발주서 화면은 열리고(담당자 = `to_jsonb(f)->>'manager'`), 공장 저장만 "002 필요" 안내.
|
||||
앱 계정 `inout_app` 은 SELECT/INSERT/UPDATE/DELETE + 시퀀스만. 초기화는 멱등(DROP·TRUNCATE 없음). 백업 권장: 매일 `pg_dump inout_db`.
|
||||
|
||||
## 7. 테스트
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
-- =====================================================================
|
||||
-- inout_db 마이그레이션 002 — 공장 담당자·연락처 분리(2026-10-16)
|
||||
-- =====================================================================
|
||||
-- 멱등(idempotent). 열 추가만, 삭제 없음. 운영: /opt/www/main 에서 기존 inout_db 에 적용(백업 먼저).
|
||||
--
|
||||
-- 왜(사용자 요청): 공장 옵션의 "담당자·연락처" 한 칸을 담당자 / 연락처 두 칸으로.
|
||||
-- inout_factories.manager(담당자) 를 추가하고 contact 는 연락처만 담는다.
|
||||
-- 예전 한 칸에 숫자 없이 이름만 들어 있던 값(예: "이석준")은 담당자로 옮긴다 — 숫자가 있으면 연락처로 보고 그대로 둔다.
|
||||
-- (manager 가 비어 있는 행만 — 다시 실행해도 같다.)
|
||||
-- 되돌리기: 백업에서 inout_factories 만 복원(열은 남아도 앱은 동작).
|
||||
-- =====================================================================
|
||||
\set ON_ERROR_STOP on
|
||||
BEGIN;
|
||||
|
||||
ALTER TABLE inout_factories ADD COLUMN IF NOT EXISTS manager TEXT NOT NULL DEFAULT '';
|
||||
COMMENT ON COLUMN inout_factories.manager IS '공장 담당자 이름(연락처는 contact)';
|
||||
|
||||
UPDATE inout_factories
|
||||
SET manager = contact, contact = ''
|
||||
WHERE manager = '' AND contact <> '' AND contact !~ '[0-9]';
|
||||
|
||||
COMMIT;
|
||||
SELECT 'inout_db 002 factory manager ready' AS status;
|
||||
@@ -49,7 +49,8 @@ $$ LANGUAGE plpgsql;
|
||||
CREATE TABLE IF NOT EXISTS inout_factories (
|
||||
id SERIAL PRIMARY KEY,
|
||||
name TEXT NOT NULL CHECK (char_length(name) BETWEEN 1 AND 100),
|
||||
contact TEXT NOT NULL DEFAULT '', -- 담당자·연락처(자유 글)
|
||||
manager TEXT NOT NULL DEFAULT '', -- 담당자 이름(002)
|
||||
contact TEXT NOT NULL DEFAULT '', -- 연락처
|
||||
memo TEXT NOT NULL DEFAULT '',
|
||||
is_active BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
sort_order INTEGER NOT NULL DEFAULT 0,
|
||||
@@ -57,6 +58,7 @@ CREATE TABLE IF NOT EXISTS inout_factories (
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT now()
|
||||
);
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS uq_inout_factories_name ON inout_factories (lower(name));
|
||||
ALTER TABLE inout_factories ADD COLUMN IF NOT EXISTS manager TEXT NOT NULL DEFAULT ''; -- 002 이전에 만든 DB 도 같게
|
||||
DROP TRIGGER IF EXISTS trg_inout_factories_updated ON inout_factories;
|
||||
CREATE TRIGGER trg_inout_factories_updated BEFORE UPDATE ON inout_factories
|
||||
FOR EACH ROW EXECUTE FUNCTION inout_set_updated_at();
|
||||
|
||||
@@ -23,7 +23,7 @@ class InoutDbTests(unittest.TestCase):
|
||||
|
||||
cls.st = InoutDBStore(DSN)
|
||||
cls.tag = uuid.uuid4().hex[:6]
|
||||
cls.fid = cls.st.save_factory(factory_id=None, name=f"테스트공장-{cls.tag}", contact="김공장 010")
|
||||
cls.fid = cls.st.save_factory(factory_id=None, name=f"테스트공장-{cls.tag}", manager="김공장", contact="010-1234")
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
@@ -44,6 +44,8 @@ class InoutDbTests(unittest.TestCase):
|
||||
def test_partial_receipts_until_done(self):
|
||||
o = self.order([("MT-A", 100), ("MT-B", 50)])
|
||||
self.assertRegex(o["order_no"], r"^PO-261016-\d{2}$")
|
||||
head = self.st.get_order(o["id"])
|
||||
self.assertEqual((head["factory_manager"], head["factory_contact"]), ("김공장", "010-1234")) # 담당자·연락처 따로(002)
|
||||
ids = self.line_ids(o["id"])
|
||||
self.assertEqual(self.st.get_order(o["id"])["status"], "open")
|
||||
self.st.add_receipt(o["id"], {ids["MT-A"]: "60"}, receipt_date="2026-10-20", memo="1차", confirm_over=False, by="w@x")
|
||||
|
||||
+25
-10
@@ -97,18 +97,32 @@ admin, buyer, wh, viewer = (U("admin-%s@t.local" % tag, role="admin"), U("buyer-
|
||||
users.extend([admin, buyer, wh, viewer])
|
||||
|
||||
def body(c):
|
||||
# ── 옵션: 공장·담당자(관리자만) ──
|
||||
# ── 옵션(톱니 팝업): 공장·담당자(관리자만) ──
|
||||
who["u"] = buyer
|
||||
assert c.get("/inout/settings").status_code == 403
|
||||
assert c.get("/inout/settings?panel=1").status_code == 403
|
||||
assert 'id="io-options-btn"' not in c.get("/inout/").text # 관리자 아니면 톱니 없음
|
||||
who["u"] = admin
|
||||
page = c.get("/inout/settings")
|
||||
assert page.status_code == 200 and buyer["email"] in page.text and "발주 담당" in page.text
|
||||
r = c.post("/inout/settings/factories", data={"name": "공장-" + tag, "contact": "김 010", "is_active": "1"},
|
||||
follow_redirects=False)
|
||||
assert r.status_code == 303 and "msg=" in r.headers["location"]
|
||||
fid = re.search(r'name="id" value="(\\d+)" />\\s*<input class="erp-input" type="text" name="name" value="공장-%s"' % tag,
|
||||
c.get("/inout/settings").text).group(1)
|
||||
c.post("/inout/settings/roles", data={"order_email": [buyer["email"]], "receive_email": [wh["email"]]})
|
||||
lst = c.get("/inout/").text
|
||||
assert 'id="io-options-btn"' in lst and 'id="io-options"' in lst and ">옵션</a>" not in lst # 탭 대신 톱니 + 팝업
|
||||
r = c.get("/inout/settings", follow_redirects=False) # 예전 주소 = 목록으로 가서 팝업 열기
|
||||
assert r.status_code == 303 and r.headers["location"] == "/inout/?options=1"
|
||||
assert 'data-open="1"' in c.get("/inout/?options=1").text
|
||||
panel = c.get("/inout/settings?panel=1").text
|
||||
assert buyer["email"] in panel and "발주 담당" in panel and "<html" not in panel.lower() # 팝업 안 내용만
|
||||
assert 'name="manager"' in panel and 'name="contact"' in panel # 담당자·연락처 따로
|
||||
H = {"X-Inout-Options": "1"}
|
||||
r = c.post("/inout/settings/factories", data={"name": "공장-" + tag, "manager": "김공장", "contact": "010-1",
|
||||
"is_active": "1"}, headers=H)
|
||||
assert r.status_code == 200 and r.json() == {"ok": True, "message": "공장을 저장했습니다."}
|
||||
dup = c.post("/inout/settings/factories", data={"name": "공장-" + tag, "is_active": "1"}, headers=H)
|
||||
assert dup.status_code == 400 and dup.json()["ok"] is False and "같은 이름" in dup.json()["message"]
|
||||
r = c.post("/inout/settings/factories", data={"name": "폼-" + tag, "is_active": "1"}, follow_redirects=False)
|
||||
assert r.status_code == 303 and r.headers["location"].startswith("/inout/?options=1&msg=") # 팝업이 아닌 제출 = 이동
|
||||
fid = next(f["id"] for f in main.app.state.inout_store.list_factories() if f["name"] == "공장-" + tag)
|
||||
f = next(x for x in main.app.state.inout_store.list_factories() if x["id"] == fid)
|
||||
assert (f["manager"], f["contact"]) == ("김공장", "010-1")
|
||||
assert c.post("/inout/settings/roles", data={"order_email": [buyer["email"]], "receive_email": [wh["email"]]},
|
||||
headers=H).json()["ok"]
|
||||
st = main.app.state.inout_store
|
||||
assert st.roles_of(buyer["email"]) == {"order"} and st.roles_of(wh["email"]) == {"receive"}
|
||||
|
||||
@@ -131,6 +145,7 @@ def body(c):
|
||||
assert r.status_code == 303, r.text[:300]
|
||||
oid = int(re.search(r"/inout/orders/(\\d+)", r.headers["location"]).group(1))
|
||||
detail = c.get(r.headers["location"]).text
|
||||
assert "김공장 · 010-1" in detail # 공장 담당자·연락처
|
||||
assert "가 단품" in detail and "포장 주의" in detail and "PO-261016-" in detail and "발주서 PO-261016-" in detail
|
||||
assert "이번 입고" not in detail # 발주 담당은 입고 칸이 없다
|
||||
assert c.post("/inout/orders/%d/receipts" % oid, data={"receipt_date": "2026-10-17"}).status_code == 403
|
||||
|
||||
Reference in New Issue
Block a user