lingo/lingo/pricing/templates/lingo/pricing/manager_agenda_pricing_deta...

196 lines
9.0 KiB
HTML

{% extends "lingo/pricing/manager_agenda_pricing_list.html" %}
{% load i18n %}
{% block breadcrumb %}
{{ block.super }}
<a href="{% url 'lingo-manager-agenda-pricing-detail' object.pk %}">{{ object }}</a>
{% endblock %}
{% block appbar %}
<h2>
{{ object }}
<span class="identifier">[{% trans "identifier:" %} {{ object.slug }}]</span>
</h2>
<span class="actions">
<a class="extra-actions-menu-opener"></a>
<ul class="extra-actions-menu">
<li><a rel="popup" href="{% url 'lingo-manager-agenda-pricing-edit' object.pk %}">{% trans 'Options' %}</a></li>
<li><a href="{% url 'lingo-manager-agenda-pricing-export' pk=object.pk %}">{% trans 'Export' %}</a></li>
<li><a rel="popup" href="{% url 'lingo-manager-agenda-pricing-delete' object.pk %}">{% trans 'Delete' %}</a></li>
</ul>
</span>
{% endblock %}
{% block content %}
{% with iter_matrix=object.iter_pricing_matrix|list agendas=object.agendas.all %}
<div class="section">
<div class="pk-tabs">
<div class="pk-tabs--tab-list" role="tablist">
<button aria-controls="panel-options" aria-selected="true" id="tab-options" role="tab" tabindex="0">{% trans "Options" %}</button>
{% if object.subscription_required %}
<button aria-controls="panel-agendas" aria-selected="false" id="tab-agendas" role="tab" tabindex="0">{% trans "Agendas" %}</button>
{% endif %}
<button aria-controls="panel-debug" aria-selected="false" id="tab-debug" role="tab" tabindex="0">{% trans "Test tool" %}</button>
{% if object.flat_fee_schedule %}
<button aria-controls="panel-billing-dates" aria-selected="false" id="tab-billing-dates" role="tab" tabindex="0">{% trans "Billing dates" %}</button>
{% endif %}
{% for matrix in iter_matrix %}
<button aria-controls="panel-matrix-{{ matrix.criteria.slug }}" aria-selected="false" id="tab-matrix-{{ matrix.criteria.slug }}" role="tab" tabindex="-1">{% trans "Pricings" context 'amount' %}{% if matrix.criteria %} - {{ matrix.criteria.label }}{% endif %}</button>
{% empty %}
<button aria-controls="panel-matrix" aria-selected="false" id="tab-matrix" role="tab" tabindex="-1">{% trans "Pricings" context 'amount' %}</button>
{% endfor %}
</div>
<div class="pk-tabs--container">
<div aria-labelledby="tab-options" id="panel-options" role="tabpanel" tabindex="0">
<ul>
<li>{% trans "Pricing model:" %} <a href="{% url 'lingo-manager-pricing-detail' object.pricing.pk %}">{{ object.pricing }}</a></li>
<li>{% blocktrans with start=object.date_start|date:'d/m/Y' end=object.date_end|date:'d/m/Y' %}From {{ start }} to {{ end }}{% endblocktrans %}</li>
<li>{% trans "Flat fee schedule:" %} {{ object.flat_fee_schedule|yesno }}</li>
{% if object.flat_fee_schedule %}
<li>{% trans "Subscription required:" %} {{ object.subscription_required|yesno }}</li>
{% endif %}
</ul>
</div>
{% if object.subscription_required %}
<div aria-labelledby="tab-agendas" hidden id="panel-agendas" role="tabpanel" tabindex="0">
<ul class="objects-list single-links">
{% for agenda in agendas %}
<li>
<a href="{% url 'lingo-manager-agenda-detail' pk=agenda.pk %}">
{{ agenda.label }}
</a>
<a class="delete" rel="popup" href="{% url 'lingo-manager-agenda-pricing-agenda-delete' object.pk agenda.pk %}">{% trans "remove"%}</a>
</li>
{% endfor %}
</ul>
<div class="panel--buttons">
<a class="pk-button" rel="popup" href="{% url 'lingo-manager-agenda-pricing-agenda-add' object.pk %}">{% trans "Add an agenda" %}</a>
</div>
</div>
{% endif %}
<div aria-labelledby="tab-debug" hidden id="panel-debug" role="tabpanel" tabindex="0">
<form method="get" enctype="multipart/form-data" action="{% url 'lingo-manager-agenda-pricing-test-tool' object.pk %}">
{{ test_tool_form.as_p }}
{% if not object.flat_fee_schedule %}
<script>
$(function() {
var presences = {};
var absences = {};
{% for agenda in agendas %}
presences['{{ agenda.pk }}'] = [];
absences['{{ agenda.pk }}'] = [];
{% for check_type in agenda.check_type_group.check_types.all %}
{% if check_type.kind == "presence" %}
presences['{{ agenda.pk }}'].push({slug: '{{ check_type.slug }}', label: '{{ check_type.label }}'});
{% else %}
absences['{{ agenda.pk }}'].push({slug: '{{ check_type.slug }}', label: '{{ check_type.label }}'});
{% endif %}
{% endfor %}
{% endfor %}
$('#id_agenda').on('change', function() {
var agenda_id = $(this).val();
var $select = $('#id_booking_status');
var current_value = $select.val();
$select.find('option').remove().end().append('<option value="presence">' + '{% trans "Presence" %}' + '</option>');
if (presences[agenda_id]) {
$.each(presences[agenda_id], function(index, value) {
$select.append('<option value="presence::' + value.slug + '">' + '{% trans "Presence" %} (' + value.label + ')</option>');
});
}
$select.append('<option value="absence">' + '{% trans "Absence" %}' + '</option>');
if (absences[agenda_id]) {
$.each(absences[agenda_id], function(index, value) {
$select.append('<option value="absence::' + value.slug + '">' + '{% trans "Absence" %} (' + value.label + ')</option>');
});
}
$select.val(current_value);
});
});
</script>
{% endif %}
<div class="buttons">
<button class="submit-button">{% trans "Compute" %}</button>
</div>
</form>
{% if request.GET and test_tool_form.is_valid %}
{% with test_tool_form.compute as pricing_data %}
<div class="test-tool-result">
<div class="infonotice">
<h3>{% trans "Computed pricing data" %}</h3>
{% if pricing_data.pricing is not None %}<p>{% trans "Pricing:" %} {{ pricing_data.pricing|stringformat:".2f" }}</p>{% endif %}
<pre>{{ pricing_data|pprint }}</pre>
</div>
</div>
{% endwith %}
{% endif %}
</div>
{% if object.flat_fee_schedule %}
<div aria-labelledby="tab-billing-dates" hidden id="panel-billing-dates" role="tabpanel" tabindex="0">
{% if billing_dates %}
<ul class="objects-list single-links">
{% for billing_date in billing_dates %}
<li>
<a rel="popup" href="{% url 'lingo-manager-agenda-pricing-billing-date-edit' object.pk billing_date.pk %}">
{{ billing_date }}
</a>
<a class="delete" rel="popup" href="{% url 'lingo-manager-agenda-pricing-billing-date-delete' object.pk billing_date.pk %}">{% trans "remove"%}</a>
</li>
{% endfor %}
</ul>
{% else %}
<div class="big-msg-info">
{% blocktrans with date_start=object.date_start|date:'d/m/Y' %}
No billing dates. The start date of the pricing ({{ date_start }}) is used as the only available billing date.
{% endblocktrans %}
</div>
{% endif %}
<div class="panel--buttons">
<a class="pk-button" rel="popup" href="{% url 'lingo-manager-agenda-pricing-billing-date-add' object.pk %}">{% trans "New billing date" %}</a>
</div>
</div>
{% endif %}
{% for matrix in iter_matrix %}
<div aria-labelledby="tab-matrix-{{ matrix.criteria.slug }}" hidden="" id="panel-matrix-{{ matrix.criteria.slug }}" role="tabpanel" tabindex="0">
<table class="main pricing-matrix-{{ matrix.criteria.slug }}">
{% if matrix.rows.0.cells.0.criteria %}
<thead>
<tr>
<th></th>
{% for cell in matrix.rows.0.cells %}<th scope="col">{{ cell.criteria.label }}</th>{% endfor %}
</tr>
</thead>
{% endif %}
<tbody>
{% for row in matrix.rows %}
<tr class="pricing-row-{{ row.criteria.slug }}">
<th scope="row">{{ row.criteria.label }}</th>
{% for cell in row.cells %}<td class="pricing-cell-{{ cell.criteria.slug }}">{{ cell.value|floatformat:"2"|default_if_none:"" }}</td>{% endfor %}
</tr>
{% endfor %}
</tbody>
</table>
<div class="panel--buttons">
<a class="pk-button" href="{% if matrix.criteria %}{% url 'lingo-manager-agenda-pricing-matrix-slug-edit' object.pk matrix.criteria.slug %}{% else %}{% url 'lingo-manager-agenda-pricing-matrix-edit' object.pk %}{% endif %}">{% trans "Edit pricing" %}</a>
</div>
</div>
{% empty %}
<div aria-labelledby="tab-matrix" hidden="" id="panel-matrix" role="tabpanel" tabindex="0">
<div class="big-msg-info">
{% blocktrans %}
This pricing model is misconfigured.
{% endblocktrans %}
</div>
</div>
{% endfor %}
</div>
</div>
</div>
{% endwith %}
{% endblock %}