89 lines
3.7 KiB
HTML
89 lines
3.7 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block page_title %}
|
|
<h4 class="mb-0">{{ '入庫' if request.args.get('type') == 'in' else '出庫' }}交易</h4>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="row justify-content-center">
|
|
<div class="col-md-8">
|
|
<div class="card">
|
|
<div class="card-header">
|
|
<h5 class="card-title mb-0">交易資料</h5>
|
|
</div>
|
|
<div class="card-body">
|
|
<form method="POST">
|
|
{{ form.csrf_token }}
|
|
|
|
<div class="row mb-4">
|
|
<div class="col-md-12">
|
|
<label class="form-label">{{ form.product_id.label }} <span class="text-danger">*</span></label>
|
|
{{ form.product_id(class="form-select" + (" is-invalid" if form.product_id.errors else "")) }}
|
|
{% if form.product_id.errors %}
|
|
<div class="invalid-feedback">
|
|
{% for error in form.product_id.errors %}
|
|
<span>{{ error }}</span>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="row mb-4">
|
|
<div class="col-md-6">
|
|
<label class="form-label">{{ form.type.label }} <span class="text-danger">*</span></label>
|
|
{{ form.type(class="form-select" + (" is-invalid" if form.type.errors else "")) }}
|
|
{% if form.type.errors %}
|
|
<div class="invalid-feedback">
|
|
{% for error in form.type.errors %}
|
|
<span>{{ error }}</span>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="form-label">{{ form.quantity.label }} <span class="text-danger">*</span></label>
|
|
{{ form.quantity(class="form-control" + (" is-invalid" if form.quantity.errors else "")) }}
|
|
{% if form.quantity.errors %}
|
|
<div class="invalid-feedback">
|
|
{% for error in form.quantity.errors %}
|
|
<span>{{ error }}</span>
|
|
{% endfor %}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="d-flex justify-content-end gap-2">
|
|
<a href="{{ url_for('transaction.list_transactions') }}" class="btn btn-light">
|
|
<i class="bi bi-x-lg me-1"></i>取消
|
|
</a>
|
|
<button type="submit" class="btn btn-primary">
|
|
<i class="bi bi-check-lg me-1"></i>確認交易
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block scripts %}
|
|
<script>
|
|
// 自動選擇交易類型
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const urlParams = new URLSearchParams(window.location.search);
|
|
const type = urlParams.get('type');
|
|
if (type) {
|
|
document.querySelector('select[name="type"]').value = type;
|
|
}
|
|
|
|
const productId = urlParams.get('product_id');
|
|
if (productId) {
|
|
document.querySelector('select[name="product_id"]').value = productId;
|
|
}
|
|
});
|
|
</script>
|
|
{% endblock %}
|