{% 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="persons-balance-table-filters" class="mb-4 d-flex align-items-center" style="gap: 20px; flex-wrap: wrap;">
{% include 'components/table_filter.html.twig' with { options: {
labelText: 'Уровень учащегося',
dropdownIdPrefix: 'level',
allItemsButtonText: 'Все уровни',
}} %}
{% include 'components/table_filter.html.twig' with { options: {
labelText: 'Статус учащегося',
dropdownIdPrefix: 'status',
allItemsButtonText: 'Все статусы',
}} %}
</div>
<div class="table-responsive">
{% set financeCategories = financeCategoryService.getAllWithIdKeys() %}
{% set hasWithoutFinanceCategory = false %}
{% for item in persons %}
{% if item.balance[-1] is defined %}
{% set hasWithoutFinanceCategory = true %}
{% endif %}
{% endfor %}
<table class="table table-bordered" id="persons-balance-table">
<thead>
<tr>
<th data-table-type="num">Номер п/п</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>
{% for id, fc in financeCategories %}
<th data-table-type="num">{{ fc.name }}</th>
{% endfor %}
{% if hasWithoutFinanceCategory %}
<th data-table-type="num">Без статьи финансов</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for item in persons %}
{% set student = item.student %}
<tr>
<td>{{ loop.index }}</td>
<td>{{ getFirstLastNameWithOld(item, false, true) }}</td>
<td>{{ student ? student.level : '–' }}</td>
<td>
<span class="btn btn-{{ item.virtualStudentStatusCssClass }} btn-icon-split w-max cursor-default">
<span class="icon text-white-50"><i class="fas fa-tag"></i></span>
<span class="text">{{ item.virtualStudentStatusText }}</span>
</span>
</td>
<td>{{ item.virtualStudentStatusText }}</td>
{% for fcId, fc in financeCategories %}
<td>{{ item.balance[fcId]|default(0) }}</td>
{% endfor %}
{% if hasWithoutFinanceCategory %}
{% if item.balance[-1] is defined %}
<td>{{ item.balance[-1] }}</td>
{% else %}
<td>0</td>
{% endif %}
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endblock %}
{% block addJs %}
<script>
let table = new CustomDataTable('#persons-balance-table', {
drawRowNumbersForColIndex: 0,
});
table.initDataTable();
</script>
{% endblock %}