05/07 Phase 3: initial codes

This commit is contained in:
2026-05-07 12:17:19 -04:00
parent 6e5518c103
commit ce462c57b2
107 changed files with 6365 additions and 208 deletions
+102
View File
@@ -0,0 +1,102 @@
{% extends "tenant/layouts/base.html" %}
{% block title %}Services & Products{% endblock %}
{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
<h4 class="fw-bold mb-0"><i class="bi bi-card-list me-2"></i>Services & Products</h4>
<div class="d-flex gap-2">
<a href="{{ url_for('services.create_service') }}" class="btn btn-primary btn-sm">+ Service</a>
<a href="{{ url_for('services.create_product') }}" class="btn btn-outline-primary btn-sm">+ Product</a>
<a href="{{ url_for('services.create_promotion') }}" class="btn btn-outline-warning btn-sm">+ Promotion</a>
</div>
</div>
<div class="row g-3">
<div class="col-lg-6">
<div class="card shadow-sm">
<div class="card-header fw-semibold">Services</div>
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light"><tr><th>Name</th><th>Category</th><th>Duration</th><th>Price</th><th></th></tr></thead>
<tbody>
{% for s in services %}
<tr class="{{ '' if s.is_active else 'text-muted' }}">
<td class="fw-semibold">{{ s.name }}</td>
<td class="small">{{ s.category or '—' }}</td>
<td class="small">{{ s.duration_min }} min</td>
<td>${{ "%.2f"|format(s.price) }}</td>
<td>
<a href="{{ url_for('services.edit_service', service_id=s.id) }}" class="btn btn-outline-secondary btn-sm">Edit</a>
<form method="POST" action="{{ url_for('services.delete_service', service_id=s.id) }}" class="d-inline"
onsubmit="return confirm('Delete this service?')">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<button class="btn btn-outline-danger btn-sm">Del</button>
</form>
</td>
</tr>
{% else %}
<tr><td colspan="5" class="text-center text-muted py-3">No services yet.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card shadow-sm">
<div class="card-header fw-semibold">Products</div>
<div class="table-responsive">
<table class="table table-hover mb-0">
<thead class="table-light"><tr><th>Name</th><th>SKU</th><th>Price</th><th></th></tr></thead>
<tbody>
{% for p in products %}
<tr class="{{ '' if p.is_active else 'text-muted' }}">
<td class="fw-semibold">{{ p.name }}</td>
<td class="small text-muted">{{ p.sku or '—' }}</td>
<td>${{ "%.2f"|format(p.sale_price) }}</td>
<td>
<a href="{{ url_for('services.edit_product', product_id=p.id) }}" class="btn btn-outline-secondary btn-sm">Edit</a>
<form method="POST" action="{{ url_for('services.delete_product', product_id=p.id) }}" class="d-inline"
onsubmit="return confirm('Delete this product?')">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<button class="btn btn-outline-danger btn-sm">Del</button>
</form>
</td>
</tr>
{% else %}
<tr><td colspan="4" class="text-center text-muted py-3">No products yet.</td></tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% if promotions %}
<div class="card shadow-sm mt-3 border-warning">
<div class="card-header fw-semibold bg-warning-subtle">Active Promotions</div>
<div class="table-responsive">
<table class="table table-sm mb-0">
<thead><tr><th>Name</th><th>Discount</th><th>Applies To</th><th>Ends</th><th></th></tr></thead>
<tbody>
{% for promo in promotions %}
<tr>
<td class="fw-semibold">{{ promo.name }}</td>
<td>{{ promo.discount_percent }}%</td>
<td class="small">{{ promo.applies_to }}</td>
<td class="small text-muted">{{ promo.ends_at.strftime('%Y-%m-%d') }}</td>
<td>
<form method="POST" action="{{ url_for('services.toggle_promotion', promo_id=promo.id) }}" class="d-inline">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<button class="btn btn-outline-{{ 'danger' if promo.is_active else 'success' }} btn-sm">
{{ 'Deactivate' if promo.is_active else 'Activate' }}
</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
{% endif %}
</div>
</div>
{% endblock %}
@@ -0,0 +1,50 @@
{% extends "tenant/layouts/base.html" %}
{% block title %}{{ 'Edit' if mode == 'edit' else 'New' }} Product{% endblock %}
{% block content %}
<div class="row justify-content-center">
<div class="col-md-5">
<div class="card shadow-sm">
<div class="card-header fw-semibold">{{ 'Edit' if mode == 'edit' else 'New' }} Product</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">Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" name="name"
value="{{ product.name if product else '' }}" required autofocus>
</div>
<div class="row g-2 mb-3">
<div class="col">
<label class="form-label">SKU</label>
<input type="text" class="form-control" name="sku"
value="{{ product.sku if product else '' }}">
</div>
<div class="col">
<label class="form-label">Category</label>
<input type="text" class="form-control" name="category"
value="{{ product.category if product else '' }}">
</div>
</div>
<div class="mb-3">
<label class="form-label">Sale Price ($) <span class="text-danger">*</span></label>
<input type="number" step="0.01" class="form-control" name="sale_price" min="0"
value="{{ "%.2f"|format(product.sale_price) if product else '' }}" required>
</div>
{% if mode == 'edit' %}
<div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox" name="is_active" value="1"
id="is_active" {{ 'checked' if product and product.is_active }}>
<label class="form-check-label" for="is_active">Active</label>
</div>
{% endif %}
<div class="d-flex gap-2">
<button type="submit" class="btn btn-primary">Save</button>
<a href="{{ url_for('services.index') }}" class="btn btn-outline-secondary">Cancel</a>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}
@@ -0,0 +1,84 @@
{% 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 %}
@@ -0,0 +1,50 @@
{% extends "tenant/layouts/base.html" %}
{% block title %}{{ 'Edit' if mode == 'edit' else 'New' }} Service{% endblock %}
{% block content %}
<div class="row justify-content-center">
<div class="col-md-5">
<div class="card shadow-sm">
<div class="card-header fw-semibold">{{ 'Edit' if mode == 'edit' else 'New' }} Service</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">Name <span class="text-danger">*</span></label>
<input type="text" class="form-control" name="name"
value="{{ service.name if service else '' }}" required autofocus>
</div>
<div class="mb-3">
<label class="form-label">Category</label>
<input type="text" class="form-control" name="category"
value="{{ service.category if service else '' }}" placeholder="e.g. Nails, Spa, Waxing">
</div>
<div class="row g-2 mb-3">
<div class="col">
<label class="form-label">Duration (min) <span class="text-danger">*</span></label>
<input type="number" class="form-control" name="duration_min" min="5" max="480"
value="{{ service.duration_min if service else 30 }}" required>
</div>
<div class="col">
<label class="form-label">Price ($) <span class="text-danger">*</span></label>
<input type="number" step="0.01" class="form-control" name="price" min="0"
value="{{ "%.2f"|format(service.price) if service else '' }}" required>
</div>
</div>
{% if mode == 'edit' %}
<div class="form-check form-switch mb-3">
<input class="form-check-input" type="checkbox" name="is_active" value="1"
id="is_active" {{ 'checked' if service and service.is_active }}>
<label class="form-check-label" for="is_active">Active</label>
</div>
{% endif %}
<div class="d-flex gap-2">
<button type="submit" class="btn btn-primary">Save</button>
<a href="{{ url_for('services.index') }}" class="btn btn-outline-secondary">Cancel</a>
</div>
</form>
</div>
</div>
</div>
</div>
{% endblock %}