Files
MyPOS/templates/tenant/services/promotion_form.html
T
2026-05-07 12:17:19 -04:00

84 lines
3.8 KiB
HTML

{% extends "tenant/layouts/base.html" %}
{% block title %}New Promotion{% endblock %}
{% block content %}
<div class="row justify-content-center">
<div class="col-md-6">
<div class="card shadow-sm">
<div class="card-header fw-semibold">New Promotion</div>
<div class="card-body">
{% if error %}<div class="alert alert-danger py-2">{{ error }}</div>{% endif %}
<form method="POST" novalidate>
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<div class="mb-3">
<label class="form-label">Promotion Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" name="name" required autofocus>
</div>
<div class="row g-2 mb-3">
<div class="col">
<label class="form-label">Discount % <span class="text-danger">*</span></label>
<input type="number" class="form-control" name="discount_percent" min="1" max="100" required>
</div>
<div class="col">
<label class="form-label">Applies To <span class="text-danger">*</span></label>
<select class="form-select" name="applies_to" id="applies_to"
onchange="toggleTargets(this.value)">
<option value="all_services">All Services</option>
<option value="all_products">All Products</option>
<option value="all">All Services & Products</option>
<option value="service">Specific Services</option>
<option value="product">Specific Products</option>
</select>
</div>
</div>
<div id="target_services" class="mb-3 d-none">
<label class="form-label">Select Services</label>
{% for svc in services %}
<div class="form-check">
<input class="form-check-input" type="checkbox" name="target_ids"
value="{{ svc.id }}" id="svc_{{ svc.id }}">
<label class="form-check-label" for="svc_{{ svc.id }}">
{{ svc.name }} — ${{ "%.2f"|format(svc.price) }}
</label>
</div>
{% endfor %}
</div>
<div id="target_products" class="mb-3 d-none">
<label class="form-label">Select Products</label>
{% for p in products %}
<div class="form-check">
<input class="form-check-input" type="checkbox" name="target_ids"
value="{{ p.id }}" id="prod_{{ p.id }}">
<label class="form-check-label" for="prod_{{ p.id }}">
{{ p.name }} — ${{ "%.2f"|format(p.sale_price) }}
</label>
</div>
{% endfor %}
</div>
<div class="row g-2 mb-3">
<div class="col">
<label class="form-label">Starts At <span class="text-danger">*</span></label>
<input type="datetime-local" class="form-control" name="starts_at" required>
</div>
<div class="col">
<label class="form-label">Ends At <span class="text-danger">*</span></label>
<input type="datetime-local" class="form-control" name="ends_at" required>
</div>
</div>
<div class="d-flex gap-2">
<button type="submit" class="btn btn-warning">Create Promotion</button>
<a href="{{ url_for('services.index') }}" class="btn btn-outline-secondary">Cancel</a>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
{% block scripts %}
<script>
function toggleTargets(val) {
document.getElementById("target_services").classList.toggle("d-none", val !== "service");
document.getElementById("target_products").classList.toggle("d-none", val !== "product");
}
</script>
{% endblock %}