451b37955e
- inout_db 003: 공장 이메일, 사람별 Gmail 연결(갱신 토큰 암호문만), 발주 메일 기록, 입고증 사진(bytea). init 에도 같게.
- 발주 메일: 새 발주서 저장 → 미리보기 팝업(받는 사람 = 공장 이메일, 요약 표 HTML + 글 본문) → 사람이 [메일 발송]을
눌러야 Gmail API(gmail.send)로 본인 Gmail 에서 발송. [Gmail 연결]은 사람마다 1회 — 고른 구글 계정 = ERP 계정 확인,
APP_ENCRYPTION_KEY(AES-GCM, AAD inout:gmail:{email})로 암호화 저장. 보낸 기록, 재발송은 확인 후(resend),
연결 끊김(invalid_grant)은 토큰 삭제 후 재연결 안내.
- 입고증 사진: 입고 저장 때 첨부(브라우저가 긴 변 2000px JPEG 로 줄임 — 7.9MB → 0.8MB), 10장·10MB, 파일 머리로 형식 검사,
입고와 한 트랜잭션. 썸네일·크게 보기(←/→)·나중에 더하기·지우기, 보기는 nosniff·CSP sandbox. 초과 확인은 브라우저가 먼저(사진 유지).
- 테스트: 메일 본문·escape·받는 주소·Gmail 연결 검사·토큰 갱신/발송(가짜 구글)·암호화, 사진 검사, 실제 PostgreSQL 저장,
실제 앱 흐름(사진 업로드·보기 헤더·권한, 메일 미리보기·연결·발송·재발송·끊김). 실제 브라우저로 팝업·사진·축소 확인.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
5.3 KiB
HTML
80 lines
5.3 KiB
HTML
{% extends "erp_base.html" %}
|
|
{% block head_extra %}<link rel="stylesheet" href="/static/inout.css?v=20261016d" />{% endblock %}
|
|
|
|
{% block content %}
|
|
<section class="io">
|
|
{% include "inout/_nav.html" %}
|
|
|
|
<form class="erp-card-block io-order-form" method="post" id="io-order-form"
|
|
action="{% if order %}/inout/orders/{{ order.id }}/edit{% else %}/inout/orders/new{% endif %}">
|
|
<div class="erp-card-block-head">
|
|
<h2>{% if order %}발주서 고치기 · {{ order.order_no }}{% else %}새 발주서{% endif %}</h2>
|
|
<span class="erp-muted">제품은 코드표의 단품에서 고릅니다</span>
|
|
</div>
|
|
{% if error %}<div class="io-error" role="alert">{% for line in error.split('\n') %}<div>{{ line }}</div>{% endfor %}</div>{% endif %}
|
|
{% if not items_enabled %}<div class="io-error" role="alert">코드표 DB(ITEMCODE_DB_URL)가 연결되지 않아 제품을 검색할 수 없습니다 — 관리자에게 알려 주세요.</div>{% endif %}
|
|
|
|
<div class="erp-form-grid">
|
|
<label class="erp-field"><span>공장 *</span>
|
|
<select name="factory_id" required>
|
|
<option value="">공장 고르기</option>
|
|
{% for f in factories %}<option value="{{ f.id }}" {% if vals.factory_id|string == f.id|string %}selected{% endif %}>{{ f.name }}</option>{% endfor %}
|
|
</select>
|
|
{% if not factories %}<span class="io-hint">공장이 없습니다 — 관리자가 옵션에서 먼저 공장을 추가해야 합니다.</span>{% endif %}
|
|
</label>
|
|
<label class="erp-field"><span>발주일 *</span><input type="date" name="order_date" value="{{ vals.order_date }}" required /></label>
|
|
<label class="erp-field"><span>입고 예정일</span><input type="date" name="due_date" value="{{ vals.due_date }}" /></label>
|
|
<label class="erp-field"><span>메모</span><input type="text" name="memo" value="{{ vals.memo }}" maxlength="500" placeholder="공장 전달 사항 등" /></label>
|
|
</div>
|
|
|
|
<div class="erp-table-wrap">
|
|
<table class="erp-table io-table io-lines" id="io-lines">
|
|
<thead><tr><th class="io-col-no">#</th><th>제품(코드·이름으로 검색)</th><th class="io-col-qty">발주 수량</th><th>줄 메모</th><th class="io-col-del"></th></tr></thead>
|
|
<tbody>
|
|
{% for ln in lines %}
|
|
{% set received = (order.lines | selectattr('item_code', 'equalto', ln.code) | map(attribute='received') | first) if order else 0 %}
|
|
<tr class="io-line">
|
|
<td class="io-col-no"></td>
|
|
<td class="io-item-cell">
|
|
<input type="hidden" name="item_code" value="{{ ln.code }}" />
|
|
<input type="hidden" name="item_name" value="{{ ln.name }}" />
|
|
<input class="erp-input io-item-search" type="text" value="{{ ln.code }}{% if ln.name %} · {{ ln.name }}{% endif %}" autocomplete="off"
|
|
placeholder="코드 또는 이름" {% if received %}readonly title="입고된 제품은 바꿀 수 없습니다(수량은 바꿀 수 있음)"{% endif %} />
|
|
{% if received %}<div class="erp-row-sub">입고 {{ '{:,}'.format(received) }}개 — 제품은 그대로, 수량만 바꿀 수 있습니다</div>{% endif %}
|
|
</td>
|
|
<td class="io-col-qty"><input class="erp-input io-qty" type="text" inputmode="numeric" name="qty" value="{{ ln.qty }}" placeholder="0" /></td>
|
|
<td><input class="erp-input" type="text" name="line_memo" value="{{ ln.memo }}" maxlength="500" /></td>
|
|
<td class="io-col-del">{% if not received %}<button type="button" class="erp-btn erp-btn-outline erp-btn-sm io-del" aria-label="이 줄 지우기" title="이 줄 지우기">✕</button>{% endif %}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
<tfoot><tr><td colspan="5">
|
|
<button type="button" class="erp-btn erp-btn-outline erp-btn-sm" id="io-add-line">+ 제품 줄 추가</button>
|
|
<span class="erp-muted io-total">합계 <b id="io-total-qty">0</b>개 · <b id="io-total-lines">0</b>종</span>
|
|
</td></tr></tfoot>
|
|
</table>
|
|
</div>
|
|
|
|
<template id="io-line-tpl">
|
|
<tr class="io-line">
|
|
<td class="io-col-no"></td>
|
|
<td class="io-item-cell">
|
|
<input type="hidden" name="item_code" value="" />
|
|
<input type="hidden" name="item_name" value="" />
|
|
<input class="erp-input io-item-search" type="text" value="" autocomplete="off" placeholder="코드 또는 이름" />
|
|
</td>
|
|
<td class="io-col-qty"><input class="erp-input io-qty" type="text" inputmode="numeric" name="qty" value="" placeholder="0" /></td>
|
|
<td><input class="erp-input" type="text" name="line_memo" value="" maxlength="500" /></td>
|
|
<td class="io-col-del"><button type="button" class="erp-btn erp-btn-outline erp-btn-sm io-del" aria-label="이 줄 지우기" title="이 줄 지우기">✕</button></td>
|
|
</tr>
|
|
</template>
|
|
|
|
<div class="io-form-actions">
|
|
<a class="erp-btn erp-btn-outline" href="{% if order %}/inout/orders/{{ order.id }}{% else %}/inout/{% endif %}">취소</a>
|
|
<button type="submit" class="erp-btn erp-btn-primary">{% if order %}고친 내용 저장{% else %}발주서 저장{% endif %}</button>
|
|
</div>
|
|
</form>
|
|
</section>
|
|
{% endblock %}
|
|
{% block scripts %}<script src="/static/inout.js?v=20261016c" defer></script>{% endblock %}
|