{% extends 'admin/base.html.twig' %}
{% block title %}Счета на оплату{% endblock %}
{% block content %}
<h1 class="h3 mb-2 text-gray-800">Счета на оплату</h1>
<div class="card shadow mb-4 mt-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Список счетов на оплату</h6>
</div>
<div class="card-body">
<div id="invoices-table-filters" class="mb-4 d-flex align-items-center" style="gap: 20px; flex-wrap: wrap;">
{% include 'components/calendar_events_component.html.twig' %}
{% include 'components/table_filter.html.twig' with { options: {
labelText: 'Мероприятие',
dropdownIdPrefix: 'calendarEvent',
allItemsButtonText: 'Все мероприятия',
}} %}
{% include 'components/table_filter.html.twig' with { options: {
labelText: 'Уровень учащегося',
dropdownIdPrefix: 'level',
allItemsButtonText: 'Все уровни',
}} %}
{% include 'components/table_filter.html.twig' with { options: {
labelText: 'Статус учащегося',
dropdownIdPrefix: 'status',
allItemsButtonText: 'Все статусы',
}} %}
{% include 'components/table_filter.html.twig' with { options: {
labelText: 'Статус счёта',
dropdownIdPrefix: 'invoiceStatus',
allItemsButtonText: 'Все статусы счёта',
}} %}
{% include 'components/table_filter.html.twig' with { options: {
labelText: 'Статья финансов',
dropdownIdPrefix: 'financeCategory',
allItemsButtonText: 'Все статьи финансов',
}} %}
</div>
<div class="table-responsive">
<table class="table table-bordered" id="invoices-data-table">
<thead>
<tr>
<th data-table-type="num">Номер п/п</th>
<th data-table-type="date-d-m-Y">Дата создания</th>
<th>Имя</th>
<th data-table-dropdown-id="levelDropdown"
data-table-badge-id="levelBadge"
data-table-dropdown-text-for-all="Все уровни">Уровень учащегося</th>
<th data-export-exclude-col>Статус учащегося</th>
<th data-table-hide-col
data-table-dropdown-id="statusDropdown"
data-table-badge-id="statusBadge"
data-table-dropdown-text-for-all="Все статусы">Статус учащегося (текст)</th>
<th data-table-dropdown-id="calendarEventDropdown"
data-table-badge-id="calendarEventBadge"
data-table-dropdown-text-for-all="Все мероприятия">Мероприятие</th>
<th>Сумма</th>
<th data-export-exclude-col
data-table-dropdown-id="invoiceStatusDropdown"
data-table-badge-id="invoiceStatusBadge"
data-table-dropdown-text-for-all="Все статусы счёта">Статус счёта</th>
<th data-table-hide-col
data-table-dropdown-id="invoiceStatusDropdown"
data-table-badge-id="invoiceStatusBadge"
data-table-dropdown-text-for-all="Все статусы счёта">Статус счёта (текст)</th>
<th data-table-dropdown-id="financeCategoryDropdown"
data-table-badge-id="financeCategoryBadge"
data-table-dropdown-text-for-all="Все статьи">Статья финансов</th>
</tr>
</thead>
<tbody>
{% set i = 0 %}
{% for item in items %}
{% set i = i + 1 %}
{% set person = item.person %}
{% set student = person ? person.student : null %}
{% set calendarEvent = item.candidate ? item.candidate.calendarEvent : null %}
<tr>
<td>{{ i }}</td>
<td>{{ item.createdAt|date('d.m.Y') }}</td>
<td>{{ person ? person.name : '–' }}</td>
<td>{{ student ? student.level : '–' }}</td>
<td>
{% if student %}
<span class="btn btn-{{ student.statusCssClass }} btn-icon-split w-max cursor-default">
<span class="icon text-white-50"><i class="fas fa-tag"></i></span>
<span class="text">{{ student.statusText }}</span>
</span>
{% else %}
–
{% endif %}
</td>
<td>{{ student ? student.statusText : '–' }}</td>
<td>{{ calendarEvent ? calendarEvent.getText() : '–' }}</td>
<td>{{ item.amount }}</td>
<td>
{% include 'components/status_button.html.twig' with { options: {
buttonClass: item.statusCssClass,
text: item.statusText,
}} %}
</td>
<td>{{ item.statusText }}</td>
<td>{{ item.financeCategory ? item.financeCategory.name : '–' }}</td>
{% endfor %}
</tbody>
</table>
</div>
<div class="mt-4 d-flex">
<button id="download-csv-btn" class="btn btn-primary">Скачать таблицу</button>
</div>
</div>
</div>
{% endblock %}
{% block addJs %}
<script>
let table = new CustomDataTable('#invoices-data-table', {
drawRowNumbersForColIndex: 0,
});
table.initDataTable();
$('#download-csv-btn').click(function() {
table.downloadCsv();
});
</script>
{% endblock %}