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.
121 lines
4.6 KiB
121 lines
4.6 KiB
{% extends "base.html" %}
|
|
|
|
{% block title %}Контрагенты{% endblock %}
|
|
|
|
{% block content %}
|
|
<h2>Добавление и список контрагентов</h2>
|
|
<div class='content-white'>
|
|
<div class='btn yellow-btn docs-btn'>
|
|
<a class="client add-client-link" href="{% url 'customer_clients_add' %}" title="Добавить контрагента">
|
|
Добавить контрагента
|
|
</a>
|
|
</div>
|
|
<div class="clear"></div>
|
|
|
|
<table id="clients" class="list{% if not page.object_list %} hidden{% endif %}">
|
|
<tr id='clients_header_row'>
|
|
<th style="width: 46%">Контрагент</th>
|
|
<th style="width: 18%">Контактное лицо</th>
|
|
<th style="width: 14%">Телефон</th>
|
|
<th style="width: 10%;">Редактировать</th>
|
|
<th style="width: 8%;">Удалить?</th>
|
|
</tr>
|
|
|
|
{% for obj in page.object_list %}
|
|
{% include "customer/clients/list_item.html" %}
|
|
{% endfor %}
|
|
<tr class='white_bg'>
|
|
<td colspan='5'>
|
|
{% include 'paginator.html' with url_list='customer_clients_list' %}
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
</div>
|
|
{% endblock %}
|
|
|
|
{% block dialogs %}
|
|
{% include "customer/clients/form.html" with form=client_form is_ajax="True" %}
|
|
|
|
<form id="client-delete-form" action="" method="post" title="Удалить контрагента" data-dialog-btn-caption="Да, я уверен">
|
|
{% csrf_token %}
|
|
<div class="errors-layout"></div>
|
|
<p>Вы уверены, что хотите удалить контрагента <span class='client'></span>?</p>
|
|
</form>
|
|
{% endblock %}
|
|
|
|
{% block js %}
|
|
<script src="{{ STATIC_URL }}js/client.commons.js"></script>
|
|
<script src="{{ STATIC_URL }}js/client.list.js"></script>
|
|
|
|
<script src="{{ STATIC_URL }}js/paginator.js"></script>
|
|
|
|
<script src="{{ STATIC_URL }}js/lib/jquery.suggestions.min.js"></script>
|
|
|
|
<script>
|
|
|
|
var index,
|
|
clientForm = $("#client-edit-form"),
|
|
clientName = $("#id_name", clientForm),
|
|
clientInn = $("#id_inn", clientForm),
|
|
clientKpp = $("#id_kpp", clientForm),
|
|
clientOqrn = $("#id_ogrn", clientForm),
|
|
clientAddress = $("#id_address", clientForm),
|
|
bankBic = $("#id_bank_bik", clientForm),
|
|
bankFullName = $("#id_bank_name", clientForm),
|
|
bankCorrespondentAccount = $("#id_bank_korr_account", clientForm),
|
|
bankInputs = [bankBic, bankFullName, bankCorrespondentAccount],
|
|
clientInputs = [clientName, clientInn, clientKpp, clientOqrn];
|
|
|
|
function join(arr) {
|
|
var separator = arguments.length > 1 ? arguments[1] : ", ";
|
|
return arr.filter(function(n){return n}).join(separator);
|
|
}
|
|
|
|
function showSuggestion(suggestion) {
|
|
|
|
var data = suggestion.data;
|
|
if (!data) return;
|
|
if (data.type === "LEGAL"|| data.type === "INDIVIDUAL" ) {
|
|
if (data.name)
|
|
clientName.val(join([data.opf && data.opf.short || "", data.name.short || data.name.full], " "));
|
|
if (data.name && data.name.full)
|
|
clientName.val(join([data.opf && data.opf.full || "", data.name.full], " "));
|
|
clientInn.val(data.inn);
|
|
clientKpp.val(data.kpp);
|
|
clientOqrn.val(data.ogrn);
|
|
if (data.address)
|
|
clientAddress.val(data.address.value);
|
|
} else {
|
|
if (data.name && data.name.full || "") {
|
|
bankFullName.val(data.name && data.name.full || "");
|
|
}
|
|
if (data.name && data.name.payment || "") {
|
|
bankFullName.val(data.name && data.name.payment || "");
|
|
}
|
|
bankBic.val(data.bic);
|
|
bankCorrespondentAccount.val(data.correspondent_account);
|
|
}
|
|
}
|
|
|
|
function fillInput(input, type) {
|
|
|
|
input.suggestions({
|
|
token: "{{ dadata_api_key }}",
|
|
type: type,
|
|
count: 5,
|
|
onSelect: showSuggestion
|
|
});
|
|
}
|
|
|
|
for (index = clientInputs.length - 1; index >= 0; --index) {
|
|
fillInput(clientInputs[index], "PARTY" );
|
|
}
|
|
|
|
for (index = bankInputs.length - 1; index >= 0; --index) {
|
|
fillInput(bankInputs[index], "BANK" );
|
|
}
|
|
|
|
</script>
|
|
|
|
{% endblock %}
|
|
|