291 lines
15 KiB
HTML
291 lines
15 KiB
HTML
{% extends "lingo/pricing/manager_pricing_list.html" %}
|
|
{% load gadjo i18n %}
|
|
|
|
{% block breadcrumb %}
|
|
{{ block.super }}
|
|
<a href="{% url 'lingo-manager-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" class="action-duplicate" href="{% url 'lingo-manager-pricing-duplicate' pk=object.pk %}">{% trans 'Duplicate' %}</a></li>
|
|
<li><a rel="popup" href="{% url 'lingo-manager-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>
|
|
<button aria-controls="panel-variables" aria-selected="false" id="tab-variables" role="tab" tabindex="-1">{% trans "Variables" %}</button>
|
|
<button aria-controls="panel-criterias" aria-selected="false" id="tab-criterias" role="tab" tabindex="-1">{% trans "Criterias" %}</button>
|
|
{% if object.kind != 'basic' %}
|
|
<button aria-controls="panel-pricing-options" aria-selected="false" id="tab-pricing-options" role="tab" tabindex="0">{% trans "Pricing options" %}</button>
|
|
{% endif %}
|
|
{% 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>{% blocktrans trimmed 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 %}
|
|
<li>{% trans "Kind of pricing:"%} {{ object.get_kind_display }}</li>
|
|
{% if object.kind == 'reduction' %}
|
|
<li>{% trans "Reduction rate (template):" %} <pre>{{ object.reduction_rate }}</pre></li>
|
|
{% elif object.kind == 'effort' %}
|
|
<li>{% trans "Pricing to be multiplied by the effort rate (template):" %} <pre>{{ object.effort_rate_target }}</pre></li>
|
|
{% endif %}
|
|
</ul>
|
|
</div>
|
|
|
|
<div aria-labelledby="tab-variables" hidden="" id="panel-variables" role="tabpanel" tabindex="0">
|
|
{% if object.extra_variables %}
|
|
<label>{% trans 'Extra variables:' %}</label>
|
|
<dl>
|
|
{% for key in object.get_extra_variables_keys %}
|
|
<dt><b>{% blocktrans %}{{ key }}:{% endblocktrans %}</b></dt>
|
|
<dd><pre>{{ object.extra_variables|get:key }}</pre></dd>
|
|
{% endfor %}
|
|
</dl>
|
|
{% endif %}
|
|
<div class="panel--buttons">
|
|
<a class="pk-button" rel="popup" href="{% url 'lingo-manager-pricing-variable-edit' pk=object.pk %}">{% trans 'Define variables' %}</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div aria-labelledby="tab-criterias" hidden="" id="panel-criterias" role="tabpanel" tabindex="0">
|
|
{% with criterias=object.criterias.all categories=object.categories.all %}
|
|
{% if categories %}
|
|
<div>
|
|
{% blocktrans trimmed %}Use drag and drop with the ⣿ handles to reorder categories.{% endblocktrans %}
|
|
</div>
|
|
{% endif %}
|
|
<div class="sortable" data-order-url="{% url 'lingo-manager-pricing-criteria-category-order' object.pk %}">
|
|
{% for category in categories %}
|
|
<div class="paragraph sortable-item" data-item-id="{{ category.pk }}">
|
|
<h4><span class="handle">⣿</span>{% trans "Category:" %} {{ category }}</h4>
|
|
<p>{% trans "Selected criterias:" %}</p>
|
|
<ul>
|
|
{% for criteria in criterias %}
|
|
{% if criteria.category == category %}
|
|
<li>{{ criteria }}</li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
</ul>
|
|
<p>
|
|
<a rel="popup" class="pk-button" href="{% url 'lingo-manager-pricing-criteria-category-edit' pk=object.pk category_pk=category.pk %}">{% trans "Change criterias selection" %}</a>
|
|
<a rel="popup" class="pk-button" href="{% url 'lingo-manager-pricing-criteria-category-delete' pk=object.pk category_pk=category.pk %}">{% trans "Remove this category" %}</a>
|
|
</p>
|
|
</div>
|
|
{% endfor %}
|
|
{% if object.categories.count < 3 %}
|
|
<div class="panel--buttons">
|
|
<a rel="popup" class="pk-button" href="{% url 'lingo-manager-pricing-criteria-category-add' pk=object.pk %}">{% trans "Add a category" %} <span class="extra-info">({% trans "max 3 categories" %})</span></a>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% endwith %}
|
|
</div>
|
|
|
|
{% if object.kind != 'basic' %}
|
|
<div aria-labelledby="tab-pricing-options" hidden id="panel-pricing-options" role="tabpanel" tabindex="0">
|
|
<ul>
|
|
<li>{% trans "Minimal pricing:" %} {{ object.min_pricing|default_if_none:"" }}</li>
|
|
</ul>
|
|
{% if object.kind == 'effort' %}
|
|
<ul>
|
|
<li>{% trans "Maximal pricing:" %} {{ object.max_pricing|default_if_none:"" }}</li>
|
|
</ul>
|
|
{% endif %}
|
|
<div class="panel--buttons">
|
|
<a class="pk-button" rel="popup" href="{% url 'lingo-manager-pricing-pricingoptions-edit' object.pk %}">{% trans "Edit pricing options" %}</a>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% 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-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-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-pricing-test-tool' object.pk %}">
|
|
{{ test_tool_form|with_template }}
|
|
{% 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-pricing-billing-date-edit' object.pk billing_date.pk %}">
|
|
{{ billing_date }}
|
|
</a>
|
|
<a class="delete" rel="popup" href="{% url 'lingo-manager-pricing-billing-date-delete' object.pk billing_date.pk %}">{% trans "remove"%}</a>
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
{% else %}
|
|
<div class="big-msg-info">
|
|
{% blocktrans trimmed 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-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 }}">{% spaceless %}
|
|
{% if object.kind == 'effort' %}
|
|
{{ cell.value|floatformat:"4"|default_if_none:"" }}
|
|
{% else %}
|
|
{{ cell.value|floatformat:"2"|default_if_none:"" }}
|
|
{% endif %}
|
|
{% endspaceless %}</td>
|
|
{% endfor %}
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
<div class="panel--buttons">
|
|
<a class="pk-button" href="{% if matrix.criteria %}{% url 'lingo-manager-pricing-matrix-slug-edit' object.pk matrix.criteria.slug %}{% else %}{% url 'lingo-manager-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 trimmed %}
|
|
This pricing is misconfigured.
|
|
{% endblocktrans %}
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endwith %}
|
|
{% endblock %}
|
|
|
|
{% block sidebar %}
|
|
<aside id="sidebar">
|
|
|
|
<h3>{% trans "Actions" %}</h3>
|
|
<a class="button button-paragraph" rel="popup" href="{% url 'lingo-manager-pricing-edit' object.pk %}">{% trans 'Options' %}</a>
|
|
<a class="button button-paragraph" href="{% url 'lingo-manager-pricing-export' pk=object.pk %}">{% trans 'Export' %}</a>
|
|
|
|
{% url 'lingo-manager-pricing-list' as object_list_url %}
|
|
{% include 'lingo/includes/application_detail_fragment.html' %}
|
|
|
|
</aside>
|
|
{% endblock %}
|