billing frontend for mariadb. setup as otb_billing for outsidethebox.top accounting. also involved with outsidethedb
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

152 lines
4.1 KiB

<!doctype html>
<html>
<head>
<title>New Service</title>
<link rel="icon" type="image/png" href="/static/favicon.png">
</head>
<body>
<h1>Add Service</h1>
<p><a href="/">Home</a></p>
<p>
<a href="/services">Back to Services</a> |
<a href="/service-templates">Service Templates</a>
</p>
<form method="post">
<input type="hidden" name="template_id" id="template_id" value="{{ preselect_template_id or '' }}">
<p>
Client<br>
<select name="client_id" required>
<option value="">Select client</option>
{% for c in clients %}
<option value="{{ c.id }}">{{ c.client_code }} - {{ c.company_name }}</option>
{% endfor %}
</select>
</p>
<p>
Load from Template<br>
<select id="template_select">
<option value="">-- select template --</option>
{% for t in templates %}
<option
value="{{ t.id }}"
data-name="{{ t.template_name }}"
data-type="{{ t.service_type }}"
data-cycle="{{ t.billing_cycle }}"
data-currency="{{ t.currency_code }}"
data-recurring="{{ t.recurring_amount }}"
data-setup="{{ t.setup_amount }}"
data-description="{{ (t.description or '')|e }}"
{% if preselect_template_id and preselect_template_id|string == t.id|string %}selected{% endif %}
>
{{ t.template_name }} ({{ t.recurring_amount|money(t.currency_code) }}{% if t.setup_amount and t.setup_amount != 0 %}, setup {{ t.setup_amount|money(t.currency_code) }}{% endif %})
</option>
{% endfor %}
</select>
</p>
<p>
Service Name<br>
<input name="service_name" required>
</p>
<p>
Service Type<br>
<select name="service_type" required>
<option value="hosting">hosting</option>
<option value="consulting">consulting</option>
<option value="crypto_infra">Crypto Infra</option>
<option value="saas">SaaS</option>
<option value="other">other</option>
</select>
</p>
<p>
Billing Cycle<br>
<select name="billing_cycle" required>
<option value="one_time">one_time</option>
<option value="monthly" selected>monthly</option>
<option value="quarterly">quarterly</option>
<option value="yearly">yearly</option>
<option value="manual">manual</option>
</select>
</p>
<p>
Currency Code<br>
<select name="currency_code" required>
<option value="CAD" selected>CAD</option>
<option value="ETHO">ETHO</option>
<option value="EGAZ">EGAZ</option>
<option value="ALT">ALT</option>
</select>
</p>
<p>
Recurring Amount<br>
<input type="number" step="0.00000001" name="recurring_amount" value="0.00000000" required>
</p>
<p>
Status<br>
<select name="status" required>
<option value="pending">pending</option>
<option value="active" selected>active</option>
<option value="suspended">suspended</option>
<option value="cancelled">cancelled</option>
</select>
</p>
<p>
Start Date<br>
<input type="date" name="start_date">
</p>
<p>
Description<br>
<textarea name="description" rows="5" cols="60"></textarea>
</p>
<p>
<button type="submit">Create Service</button>
</p>
</form>
<script>
(function() {
var select = document.getElementById("template_select");
var hiddenTemplateId = document.getElementById("template_id");
if (!select || !hiddenTemplateId) return;
function applySelectedTemplate() {
var opt = select.options[select.selectedIndex];
if (!opt || !opt.dataset || !opt.dataset.name) {
hiddenTemplateId.value = "";
return;
}
hiddenTemplateId.value = opt.value || "";
document.querySelector('[name="service_name"]').value = opt.dataset.name || '';
document.querySelector('[name="service_type"]').value = opt.dataset.type || 'other';
document.querySelector('[name="billing_cycle"]').value = opt.dataset.cycle || 'monthly';
document.querySelector('[name="currency_code"]').value = opt.dataset.currency || 'CAD';
document.querySelector('[name="recurring_amount"]').value = opt.dataset.recurring || '0.00000000';
document.querySelector('[name="description"]').value = opt.dataset.description || '';
}
select.addEventListener("change", applySelectedTemplate);
if (hiddenTemplateId.value) {
applySelectedTemplate();
}
})();
</script>
{% include "footer.html" %}
</body>
</html>