fix: agreement cancellation FIFO semantics, modal rendering, and list status badges

This commit is contained in:
Арсентьев Александр
2026-09-30 22:50:11 +03:00
parent 39adbf32e2
commit bc69e52174
16 changed files with 2056 additions and 16 deletions
+3 -3
View File
@@ -11,12 +11,12 @@
{% for row in line_rows %}<tr><td>{% if row.line.change_type == 'new_position' %}<span class="badge text-bg-info">&#1053;&#1086;&#1074;&#1072;&#1103;</span>{% elif row.line.change_type == 'decrease' %}<span class="badge text-bg-warning">&#1059;&#1084;&#1077;&#1085;&#1100;&#1096;&#1077;&#1085;&#1080;&#1077;</span>{% else %}<span class="badge text-bg-primary">&#1059;&#1074;&#1077;&#1083;&#1080;&#1095;&#1077;&#1085;&#1080;&#1077;</span>{% endif %}</td><td class="item-name"><div class="fw-semibold">{{ row.item.source_number or '' }} {{ row.item.name }}</div><small class="text-muted">{{ row.item.model or '' }}{% if row.item.manufacturer %} · {{ row.item.manufacturer }}{% endif %}</small></td><td>{{ row.item.unit or '—' }}</td><td class="text-end numeric">{{ row.before_quantity }}</td><td class="text-end numeric">{{ row.line.quantity_delta }}</td><td class="text-end numeric">{{ row.after_quantity }}</td><td class="text-end numeric">{{ row.amount_delta|money(project.currency) }}</td><td class="text-end">{% if agreement.status == 'draft' %}<button class="btn btn-sm btn-outline-secondary" type="button" data-bs-toggle="collapse" data-bs-target="#edit-line-{{ row.line.id }}">&#1055;&#1088;&#1072;&#1074;&#1080;&#1090;&#1100;</button><form class="d-inline" method="post" action="/projects/{{ project.id }}/agreements/{{ agreement.id }}/items/{{ row.line.id }}/delete" onsubmit="return confirm('Удалить позицию из черновика?')"><button class="btn btn-sm btn-outline-danger">&times;</button></form>{% endif %}</td></tr>
{% if agreement.status == 'draft' %}<tr class="collapse" id="edit-line-{{ row.line.id }}"><td colspan="8"><form class="row g-2" method="post" action="/projects/{{ project.id }}/agreements/{{ agreement.id }}/items/{{ row.line.id }}/edit"><div class="col-md-2"><label class="form-label">&#916; &#1082;&#1086;&#1083;-&#1074;&#1086;</label><input class="form-control" type="number" step="0.0001" name="quantity_delta" value="{{ row.line.quantity_delta }}" required></div>{% if row.line.change_type == 'new_position' %}<div class="col-md-2"><label class="form-label">&#1048;&#1084;&#1103;</label><input class="form-control" name="name" value="{{ row.item.name }}" required></div><div class="col-md-2"><label class="form-label">&#1052;&#1086;&#1076;&#1077;&#1083;&#1100;</label><input class="form-control" name="model" value="{{ row.item.model or '' }}"></div><div class="col-md-2"><label class="form-label">&#1055;&#1088;&#1086;&#1080;&#1079;&#1074;.</label><input class="form-control" name="manufacturer" value="{{ row.item.manufacturer or '' }}"></div><div class="col-md-2"><label class="form-label">&#1045;&#1076;.</label><input class="form-control" name="unit" value="{{ row.item.unit or '' }}"></div><div class="col-md-2"><label class="form-label">&#1062;&#1077;&#1085;&#1072;</label><input class="form-control" type="number" step="0.000000000001" name="unit_price" value="{{ row.item.unit_price }}" required></div><div class="col-md-3"><label class="form-label">&#1057;&#1080;&#1089;&#1090;&#1077;&#1084;&#1072;</label><select class="form-select system-select" name="system_id" required>{% for system in systems %}<option value="{{ system.id }}" {% if row.item.system_id == system.id %}selected{% endif %}>{{ system.name }}</option>{% endfor %}</select></div><div class="col-md-3"><label class="form-label">&#1056;&#1072;&#1079;&#1076;&#1077;&#1083;</label><select class="form-select section-select" name="section_id" required>{% for section in sections %}<option value="{{ section.id }}" data-system="{{ section.system_id }}" {% if row.item.section_id == section.id %}selected{% endif %}>{{ section.name }}</option>{% endfor %}</select></div>{% endif %}<div class="col-md-2 align-self-end"><button class="btn btn-primary">&#1057;&#1086;&#1093;&#1088;&#1072;&#1085;&#1080;&#1090;&#1100;</button></div></form></td></tr>{% endif %}
{% else %}<tr><td colspan="8" class="text-center text-muted py-4">&#1055;&#1086;&#1079;&#1080;&#1094;&#1080;&#1080; &#1077;&#1097;&#1105; &#1085;&#1077; &#1076;&#1086;&#1073;&#1072;&#1074;&#1083;&#1077;&#1085;&#1099;.</td></tr>{% endfor %}</tbody></table></div><div class="card-footer bg-white d-flex justify-content-between"><span class="text-muted">&#1057;&#1091;&#1084;&#1084;&#1072; &#1080;&#1079;&#1084;&#1077;&#1085;&#1077;&#1085;&#1080;&#1103; &#1087;&#1083;&#1072;&#1085;&#1072;</span><strong>{{ change_amount|money(project.currency) }}</strong></div></section>
{% if agreement.status == 'draft' %}<div class="row g-4"><div class="col-xl-6"><section class="card border-0 shadow-sm h-100"><div class="card-header bg-white"><h2 class="h5 mb-0">&#1044;&#1086;&#1073;&#1072;&#1074;&#1080;&#1090;&#1100; &#1089;&#1091;&#1097;&#1077;&#1089;&#1090;&#1074;&#1091;&#1102;&#1097;&#1091;&#1102; &#1087;&#1086;&#1079;&#1080;&#1094;&#1080;&#1102;</h2></div><form method="post" action="/projects/{{ project.id }}/agreements/{{ agreement.id }}/items/existing"><div class="card-body"><div class="mb-3 position-relative" data-position-picker><label class="form-label" for="existing-position-search">&#1055;&#1086;&#1079;&#1080;&#1094;&#1080;&#1103; &#1087;&#1088;&#1086;&#1077;&#1082;&#1090;&#1072;</label><div class="input-group"><input id="existing-position-search" class="form-control" type="search" autocomplete="off" placeholder="&#1055;&#1086;&#1080;&#1089;&#1082; &#1087;&#1086; &#1085;&#1086;&#1084;&#1077;&#1088;&#1091;, &#1085;&#1072;&#1080;&#1084;&#1077;&#1085;&#1086;&#1074;&#1072;&#1085;&#1080;&#1102;, &#1084;&#1086;&#1076;&#1077;&#1083;&#1080;, &#1089;&#1080;&#1089;&#1090;&#1077;&#1084;&#1077;..." aria-expanded="false" aria-controls="existing-position-results" required><button class="btn btn-outline-secondary" type="button" data-clear-position>&#1054;&#1095;&#1080;&#1089;&#1090;&#1080;&#1090;&#1100;</button></div><input type="hidden" name="work_item_id" data-work-item-id><div class="form-text" data-selected-position aria-live="polite">&#1055;&#1086;&#1079;&#1080;&#1094;&#1080;&#1103; &#1085;&#1077; &#1074;&#1099;&#1073;&#1088;&#1072;&#1085;&#1072;</div><div id="existing-position-results" class="list-group position-absolute shadow bg-white" role="listbox" style="z-index:1050;max-height:18rem;overflow-y:auto;min-width:min(100%,40rem);display:none">{% for row in selectable_items %}<button type="button" class="list-group-item list-group-item-action autocomplete-position" role="option" data-id="{{ row.item.id }}" data-search="{{ row.item.source_number or '' }} {{ row.item.name }} {{ row.item.model or '' }} {{ row.item.manufacturer or '' }} {{ row.item.system.name if row.item.system else '' }} {{ row.item.section.name if row.item.section else '' }}" data-label="{{ row.item.system.name if row.item.system else '' }} ? {{ row.item.section.name if row.item.section else '' }} ? ?{{ row.item.source_number or '' }} ? {{ row.item.name }}{% if row.item.model %} ? {{ row.item.model }}{% endif %} ? {{ row.quantity }} {{ row.item.unit or '' }}"><span class="fw-semibold">{{ row.item.system.name if row.item.system else '' }} ? {{ row.item.section.name if row.item.section else '' }} ? ?{{ row.item.source_number or '?' }}</span><br>{{ row.item.name }}{% if row.item.model %} ? {{ row.item.model }}{% endif %}<small class="d-block text-muted">{{ row.item.manufacturer or '' }}{% if row.item.manufacturer %} ? {% endif %}{{ row.quantity }} {{ row.item.unit or '' }}</small></button>{% endfor %}<div class="list-group-item text-muted d-none" data-no-results>&#1053;&#1080;&#1095;&#1077;&#1075;&#1086; &#1085;&#1077; &#1085;&#1072;&#1081;&#1076;&#1077;&#1085;&#1086;.</div><div class="list-group-item text-muted d-none" data-more-results>&#1055;&#1086;&#1082;&#1072;&#1079;&#1072;&#1085;&#1099; &#1087;&#1077;&#1088;&#1074;&#1099;&#1077; 20 &#1088;&#1077;&#1079;&#1091;&#1083;&#1100;&#1090;&#1072;&#1090;&#1086;&#1074;. &#1059;&#1090;&#1086;&#1095;&#1085;&#1080;&#1090;&#1077; &#1087;&#1086;&#1080;&#1089;&#1082;.</div></div></div><div class="mb-3"><label class="form-label">&#916; &#1082;&#1086;&#1083;&#1080;&#1095;&#1077;&#1089;&#1090;&#1074;&#1086; (+ / −)</label><input class="form-control" type="number" step="0.0001" name="quantity_delta" required><div class="form-text">&#1044;&#1083;&#1103; &#1091;&#1084;&#1077;&#1085;&#1100;&#1096;&#1077;&#1085;&#1080;&#1103; &#1091;&#1082;&#1072;&#1078;&#1080;&#1090;&#1077; &#1086;&#1090;&#1088;&#1080;&#1094;&#1072;&#1090;&#1077;&#1083;&#1100;&#1085;&#1086;&#1077; &#1095;&#1080;&#1089;&#1083;&#1086;. &#1057;&#1091;&#1084;&#1084;&#1072; &#1088;&#1072;&#1089;&#1089;&#1095;&#1080;&#1090;&#1072;&#1077;&#1090;&#1089;&#1103; &#1087;&#1086; &#1094;&#1077;&#1085;&#1077; &#1087;&#1086;&#1079;&#1080;&#1094;&#1080;&#1080;.</div></div>{% if not selectable_items %}<div class="text-muted small mb-3">&#1042; &#1101;&#1090;&#1086;&#1081; &#1086;&#1073;&#1083;&#1072;&#1089;&#1090;&#1080; &#1085;&#1077;&#1090; &#1085;&#1077;&#1076;&#1086;&#1073;&#1072;&#1074;&#1083;&#1077;&#1085;&#1085;&#1099;&#1093; &#1087;&#1086;&#1079;&#1080;&#1094;.</div>{% endif %}</div><div class="card-footer bg-white"><button class="btn btn-outline-primary" {% if not selectable_items %}disabled{% endif %}>&#1044;&#1086;&#1073;&#1072;&#1074;&#1080;&#1090;&#1100; &#1087;&#1086;&#1079;&#1080;&#1094;&#1080;&#1102;</button></div></form></section></div>
{% if agreement.status == 'draft' %}<div class="row g-4"><div class="col-xl-6"><section class="card border-0 shadow-sm h-100"><div class="card-header bg-white"><h2 class="h5 mb-0">&#1044;&#1086;&#1073;&#1072;&#1074;&#1080;&#1090;&#1100; &#1089;&#1091;&#1097;&#1077;&#1089;&#1090;&#1074;&#1091;&#1102;&#1097;&#1091;&#1102; &#1087;&#1086;&#1079;&#1080;&#1094;&#1080;&#1102;</h2></div><form method="post" action="/projects/{{ project.id }}/agreements/{{ agreement.id }}/items/existing"><div class="card-body"><div class="mb-3 position-relative" data-position-picker><label class="form-label" for="existing-position-search">&#1055;&#1086;&#1079;&#1080;&#1094;&#1080;&#1103; &#1087;&#1088;&#1086;&#1077;&#1082;&#1090;&#1072;</label><div class="input-group"><input id="existing-position-search" class="form-control" type="search" autocomplete="off" placeholder="&#1055;&#1086;&#1080;&#1089;&#1082; &#1087;&#1086; &#1085;&#1086;&#1084;&#1077;&#1088;&#1091;, &#1085;&#1072;&#1080;&#1084;&#1077;&#1085;&#1086;&#1074;&#1072;&#1085;&#1080;&#1102;, &#1084;&#1086;&#1076;&#1077;&#1083;&#1080;, &#1089;&#1080;&#1089;&#1090;&#1077;&#1084;&#1077;..." aria-expanded="false" aria-controls="existing-position-results" required><button class="btn btn-outline-secondary" type="button" data-clear-position>&#1054;&#1095;&#1080;&#1089;&#1090;&#1080;&#1090;&#1100;</button></div><input type="hidden" name="work_item_id" data-work-item-id><div class="form-text" data-selected-position aria-live="polite">&#1055;&#1086;&#1079;&#1080;&#1094;&#1080;&#1103; &#1085;&#1077; &#1074;&#1099;&#1073;&#1088;&#1072;&#1085;&#1072;</div><div id="existing-position-results" class="list-group position-absolute shadow bg-white" role="listbox" style="z-index:1050;max-height:18rem;overflow-y:auto;min-width:min(100%,40rem);display:none">{% for row in selectable_items %}<button type="button" class="list-group-item list-group-item-action autocomplete-position" role="option" data-id="{{ row.item.id }}" data-search="{{ row.item.source_number or '' }} {{ row.item.name }} {{ row.item.model or '' }} {{ row.item.manufacturer or '' }} {{ row.item.system.name if row.item.system else '' }} {{ row.item.section.name if row.item.section else '' }}" data-label="{{ row.item.system.name if row.item.system else '' }} · {{ row.item.section.name if row.item.section else '' }} · {{ row.item.source_number or '' }} · {{ row.item.name }}{% if row.item.model %} · {{ row.item.model }}{% endif %} · {{ row.quantity }} {{ row.item.unit or '' }}"><span class="fw-semibold">{{ row.item.system.name if row.item.system else '' }} · {{ row.item.section.name if row.item.section else '' }} · {{ row.item.source_number or '?' }}</span><br>{{ row.item.name }}{% if row.item.model %} · {{ row.item.model }}{% endif %}<small class="d-block text-muted">{{ row.item.manufacturer or '' }}{% if row.item.manufacturer %} · {% endif %}{{ row.quantity }} {{ row.item.unit or '' }}</small></button>{% endfor %}<div class="list-group-item text-muted d-none" data-no-results>&#1053;&#1080;&#1095;&#1077;&#1075;&#1086; &#1085;&#1077; &#1085;&#1072;&#1081;&#1076;&#1077;&#1085;&#1086;.</div><div class="list-group-item text-muted d-none" data-more-results>&#1055;&#1086;&#1082;&#1072;&#1079;&#1072;&#1085;&#1099; &#1087;&#1077;&#1088;&#1074;&#1099;&#1077; 20 &#1088;&#1077;&#1079;&#1091;&#1083;&#1100;&#1090;&#1072;&#1090;&#1086;&#1074;. &#1059;&#1090;&#1086;&#1095;&#1085;&#1080;&#1090;&#1077; &#1087;&#1086;&#1080;&#1089;&#1082;.</div></div></div><div class="mb-3"><label class="form-label">&#916; &#1082;&#1086;&#1083;&#1080;&#1095;&#1077;&#1089;&#1090;&#1074;&#1086; (+ / −)</label><input class="form-control" type="number" step="0.0001" name="quantity_delta" required><div class="form-text">&#1044;&#1083;&#1103; &#1091;&#1084;&#1077;&#1085;&#1100;&#1096;&#1077;&#1085;&#1080;&#1103; &#1091;&#1082;&#1072;&#1078;&#1080;&#1090;&#1077; &#1086;&#1090;&#1088;&#1080;&#1094;&#1072;&#1090;&#1077;&#1083;&#1100;&#1085;&#1086;&#1077; &#1095;&#1080;&#1089;&#1083;&#1086;. &#1057;&#1091;&#1084;&#1084;&#1072; &#1088;&#1072;&#1089;&#1089;&#1095;&#1080;&#1090;&#1072;&#1077;&#1090;&#1089;&#1103; &#1087;&#1086; &#1094;&#1077;&#1085;&#1077; &#1087;&#1086;&#1079;&#1080;&#1094;&#1080;&#1080;.</div></div>{% if not selectable_items %}<div class="text-muted small mb-3">&#1042; &#1101;&#1090;&#1086;&#1081; &#1086;&#1073;&#1083;&#1072;&#1089;&#1090;&#1080; &#1085;&#1077;&#1090; &#1085;&#1077;&#1076;&#1086;&#1073;&#1072;&#1074;&#1083;&#1077;&#1085;&#1085;&#1099;&#1093; &#1087;&#1086;&#1079;&#1080;&#1094;.</div>{% endif %}</div><div class="card-footer bg-white"><button class="btn btn-outline-primary" {% if not selectable_items %}disabled{% endif %}>&#1044;&#1086;&#1073;&#1072;&#1074;&#1080;&#1090;&#1100; &#1087;&#1086;&#1079;&#1080;&#1094;&#1080;&#1102;</button></div></form></section></div>
<div class="col-xl-6"><section class="card border-0 shadow-sm h-100"><div class="card-header bg-white"><h2 class="h5 mb-0">&#1044;&#1086;&#1073;&#1072;&#1074;&#1080;&#1090;&#1100; &#1085;&#1086;&#1074;&#1091;&#1102; &#1087;&#1086;&#1079;&#1080;&#1094;&#1080;&#1102;</h2></div><form method="post" action="/projects/{{ project.id }}/agreements/{{ agreement.id }}/items/new" data-new-item-form data-system-url="/projects/{{ project.id }}/agreements/{{ agreement.id }}/systems" data-section-url="/projects/{{ project.id }}/agreements/{{ agreement.id }}/sections"><div class="card-body row g-3"><div class="col-12"><label class="form-label">&#1042;&#1077;&#1076;&#1086;&#1084;&#1086;&#1089;&#1090;&#1100; (&#1085;&#1077;&#1086;&#1073;&#1103;&#1079;&#1072;&#1090;&#1077;&#1083;&#1100;&#1085;&#1086;)</label><select class="form-select" name="source_boq_document_id"><option value="">&#1041;&#1077;&#1079; &#1074;&#1077;&#1076;&#1086;&#1084;&#1086;&#1089;&#1090;&#1080;</option>{% for doc in boq_documents %}<option value="{{ doc.id }}" {% if agreement.boq_document_id == doc.id %}selected{% endif %}>{{ doc.display_name }}</option>{% endfor %}</select></div><div class="col-md-6"><label class="form-label">&#1053;&#1072;&#1080;&#1084;&#1077;&#1085;&#1086;&#1074;&#1072;&#1085;&#1080;&#1077;</label><input class="form-control" name="name" required></div><div class="col-md-6"><label class="form-label">&#1052;&#1086;&#1076;&#1077;&#1083;&#1100; / &#1072;&#1088;&#1090;&#1080;&#1082;&#1091;&#1083;</label><input class="form-control" name="model"></div><div class="col-md-6"><label class="form-label">&#1055;&#1088;&#1086;&#1080;&#1079;&#1074;&#1086;&#1076;&#1080;&#1090;&#1077;&#1083;&#1100;</label><input class="form-control" name="manufacturer"></div><div class="col-md-3"><label class="form-label">&#1045;&#1076;&#1080;&#1085;&#1080;&#1094;&#1072;</label><input class="form-control" name="unit"></div><div class="col-md-3"><label class="form-label">&#916; &#1082;&#1086;&#1083;-&#1074;&#1086;</label><input class="form-control" type="number" min="0.0001" step="0.0001" name="quantity_delta" required></div><div class="col-md-6"><label class="form-label">&#1062;&#1077;&#1085;&#1072; &#1079;&#1072; &#1077;&#1076;&#1080;&#1085;&#1080;&#1094;&#1091;</label><input class="form-control" type="number" min="0" step="0.000000000001" name="unit_price" required></div><div class="col-md-6"><label class="form-label">&#1057;&#1080;&#1089;&#1090;&#1077;&#1084;&#1072;</label><select class="form-select system-select" name="system_id" data-system-select><option value="">&#1041;&#1077;&#1079; &#1089;&#1080;&#1089;&#1090;&#1077;&#1084;&#1099;</option>{% for system in systems %}<option value="{{ system.id }}">{{ system.name }}</option>{% endfor %}<option value="__new__">+ &#1053;&#1086;&#1074;&#1072;&#1103; &#1089;&#1080;&#1089;&#1090;&#1077;&#1084;&#1072;...</option></select><div class="input-group mt-2 d-none" data-new-system-panel><input class="form-control" maxlength="255" placeholder="&#1053;&#1072;&#1079;&#1074;&#1072;&#1085;&#1080;&#1077; &#1089;&#1080;&#1089;&#1090;&#1077;&#1084;&#1099;"><button type="button" class="btn btn-outline-primary" data-create-system>&#1057;&#1086;&#1079;&#1076;&#1072;&#1090;&#1100;</button></div></div><div class="col-md-6"><label class="form-label">&#1056;&#1072;&#1079;&#1076;&#1077;&#1083;</label><select class="form-select section-select" name="section_id" data-section-select><option value="">&#1041;&#1077;&#1079; &#1088;&#1072;&#1079;&#1076;&#1077;&#1083;&#1072;</option>{% for section in sections %}<option value="{{ section.id }}" data-system="{{ section.system_id }}">{{ section.name }}</option>{% endfor %}<option value="__new__">+ &#1053;&#1086;&#1074;&#1099;&#1081; &#1088;&#1072;&#1079;&#1076;&#1077;&#1083;...</option></select><div class="input-group mt-2 d-none" data-new-section-panel><input class="form-control" maxlength="255" placeholder="&#1053;&#1072;&#1079;&#1074;&#1072;&#1085;&#1080;&#1077; &#1088;&#1072;&#1079;&#1076;&#1077;&#1083;&#1072;"><button type="button" class="btn btn-outline-primary" data-create-section>&#1057;&#1086;&#1079;&#1076;&#1072;&#1090;&#1100;</button></div></div><div class="col-12 text-danger small" data-association-error role="alert"></div></div><div class="card-footer bg-white"><button class="btn btn-outline-primary">&#1044;&#1086;&#1073;&#1072;&#1074;&#1080;&#1090;&#1100; &#1085;&#1086;&#1074;&#1091;&#1102; &#1087;&#1086;&#1079;&#1080;&#1094;&#1080;&#1102;</button></div></form></section></div></div>
<section class="d-flex justify-content-end mt-4"><button class="btn btn-success" data-bs-toggle="modal" data-bs-target="#approveModal" {% if not line_rows %}disabled{% endif %}>&#1059;&#1090;&#1074;&#1077;&#1088;&#1076;&#1080;&#1090;&#1100;</button></section>
<div class="modal fade" id="approveModal" tabindex="-1"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><h2 class="modal-title fs-5">&#1055;&#1086;&#1076;&#1090;&#1074;&#1077;&#1088;&#1076;&#1080;&#1090;&#1077; &#1091;&#1090;&#1074;&#1077;&#1088;&#1078;&#1076;&#1077;&#1085;&#1080;&#1077;</h2><button type="button" class="btn-close" data-bs-dismiss="modal"></button></div><div class="modal-body"><div><strong>&#1044;&#1057; &#8470;{{ agreement.number }}</strong></div><div>&#1054;&#1073;&#1083;&#1072;&#1089;&#1090;&#1100;: {{ scope_label }}</div><div>&#1050;&#1086;&#1083;&#1080;&#1095;&#1077;&#1089;&#1090;&#1074;&#1086; &#1087;&#1086;&#1079;&#1080;&#1094;&#1080;&#1081;: {{ line_rows|length }}</div><p class="text-warning mt-3 mb-0">&#1055;&#1086;&#1089;&#1083;&#1077; &#1091;&#1090;&#1074;&#1077;&#1088;&#1078;&#1076;&#1077;&#1085;&#1080;&#1103; &#1080;&#1079;&#1084;&#1077;&#1085;&#1077;&#1085;&#1080;&#1103; &#1085;&#1077;&#1083;&#1100;&#1079;&#1103; &#1088;&#1077;&#1076;&#1072;&#1082;&#1090;&#1080;&#1088;&#1086;&#1074;&#1072;&#1090;&#1100;.</p></div><div class="modal-footer"><button class="btn btn-outline-secondary" data-bs-dismiss="modal">&#1054;&#1090;&#1084;&#1077;&#1085;&#1072;</button><form method="post" action="/projects/{{ project.id }}/agreements/{{ agreement.id }}/approve"><button class="btn btn-success">&#1059;&#1090;&#1074;&#1077;&#1088;&#1076;&#1080;&#1090;&#1100; &#1044;&#1057;</button></form></div></div></div></div>
<div class="modal fade" id="deleteAgreementModal" tabindex="-1"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><h2 class="modal-title fs-5">Удалить черновик ДС</h2><button type="button" class="btn-close" data-bs-dismiss="modal"></button></div><div class="modal-body"><p>Будет удалён весь документ <strong>ДС №{{ agreement.number }}</strong> и все его позиции ({{ line_rows|length }} шт.).</p><p class="text-danger mb-0">Действие необратимо.</p></div><div class="modal-footer"><button class="btn btn-outline-secondary" data-bs-dismiss="modal">Отмена</button><form method="post" action="/projects/{{ project.id }}/agreements/{{ agreement.id }}/delete"><button class="btn btn-danger"><div class="modal fade" id="cancelAgreementModal" tabindex="-1"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><h2 class="modal-title fs-5">Отменить ДС</h2><button type="button" class="btn-close" data-bs-dismiss="modal"></button></div><div class="modal-body"><p>После отмены ДС перестанет участвовать в согласованном плане. История ДС сохранится.</p></div><div class="modal-footer"><button class="btn btn-outline-secondary" data-bs-dismiss="modal">Назад</button><form method="post" action="/projects/{{ project.id }}/agreements/{{ agreement.id }}/cancel"><button class="btn btn-warning">Отменить ДС</button></form></div></div></div></div>Удалить ДС</button></form></div></div></div></div>
{% else %}<div class="alert alert-info">&#1044;&#1057; &#1091;&#1090;&#1074;&#1077;&#1088;&#1078;&#1076;&#1077;&#1085;&#1086;. &#1048;&#1079;&#1084;&#1077;&#1085;&#1077;&#1085;&#1080;&#1103; &#1085;&#1077;&#1076;&#1086;&#1089;&#1090;&#1091;&#1087;&#1085;&#1099;.</div>{% endif %}
<div class="modal fade" id="approveModal" tabindex="-1"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><h2 class="modal-title fs-5">&#1055;&#1086;&#1076;&#1090;&#1074;&#1077;&#1088;&#1076;&#1080;&#1090;&#1077; &#1091;&#1090;&#1074;&#1077;&#1088;&#1078;&#1076;&#1077;&#1085;&#1080;&#1077;</h2><button type="button" class="btn-close" data-bs-dismiss="modal"></button></div><div class="modal-body"><div><strong>&#1044;&#1057; &#8470;{{ agreement.number }}</strong></div><div>&#1054;&#1073;&#1083;&#1072;&#1089;&#1090;&#1100;: {{ scope_label }}</div><div>&#1050;&#1086;&#1083;&#1080;&#1095;&#1077;&#1089;&#1090;&#1074;&#1086; &#1087;&#1086;&#1079;&#1080;&#1094;&#1080;&#1081;: {{ line_rows|length }}</div><p class="text-warning mt-3 mb-0">&#1055;&#1086;&#1089;&#1083;&#1077; &#1091;&#1090;&#1074;&#1077;&#1088;&#1078;&#1076;&#1077;&#1085;&#1080;&#1103; &#1080;&#1079;&#1084;&#1077;&#1085;&#1077;&#1085;&#1080;&#1103; &#1085;&#1077;&#1083;&#1100;&#1079;&#1103; &#1088;&#1077;&#1076;&#1072;&#1082;&#1090;&#1080;&#1088;&#1086;&#1074;&#1072;&#1090;&#1100;.</p></div><div class="modal-footer"><button class="btn btn-outline-secondary" data-bs-dismiss="modal">&#1054;&#1090;&#1084;&#1077;&#1085;&#1072;</button><form method="post" action="/projects/{{ project.id }}/agreements/{{ agreement.id }}/approve"><button class="btn btn-success">&#1059;&#1090;&#1074;&#1077;&#1088;&#1076;&#1080;&#1090;&#1100; &#1044;&#1057;</button></form></div></div></div></div><div class="modal fade" id="deleteAgreementModal" tabindex="-1"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><h2 class="modal-title fs-5">Удалить черновик ДС</h2><button type="button" class="btn-close" data-bs-dismiss="modal"></button></div><div class="modal-body"><p>Будет удалён весь документ <strong>ДС №{{ agreement.number }}</strong> и все его позиции ({{ line_rows|length }} шт.).</p><p class="text-danger mb-0">Действие необратимо.</p></div><div class="modal-footer"><button class="btn btn-outline-secondary" data-bs-dismiss="modal">Отмена</button><form method="post" action="/projects/{{ project.id }}/agreements/{{ agreement.id }}/delete"><button class="btn btn-danger">Удалить ДС</button></form></div></div></div></div><div class="modal fade" id="cancelAgreementModal" tabindex="-1"><div class="modal-dialog"><div class="modal-content"><div class="modal-header"><h2 class="modal-title fs-5">Отменить ДС</h2><button type="button" class="btn-close" data-bs-dismiss="modal"></button></div><div class="modal-body"><p>После отмены ДС перестанет участвовать в согласованном плане. История ДС сохранится.</p></div><div class="modal-footer"><button class="btn btn-outline-secondary" data-bs-dismiss="modal">Назад</button><form method="post" action="/projects/{{ project.id }}/agreements/{{ agreement.id }}/cancel"><button class="btn btn-warning">Отменить ДС</button></form></div></div></div></div>
</main><script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script><script>
document.querySelectorAll('.system-select').forEach(systemSelect=>{const form=systemSelect.closest('form');const section=form.querySelector('.section-select');if(!section)return;const filter=()=>{const value=systemSelect.value;[...section.options].forEach(option=>{if(!option.dataset.system)return;option.hidden=!!value&&value!=='__new__'&&option.dataset.system!==value;});const selected=section.selectedOptions[0];if(selected&&selected.dataset.system&&selected.hidden)section.value='';};systemSelect.addEventListener('change',filter);filter();});
const makeOption=(select,id,name,attributes={})=>{const option=document.createElement('option');option.value=id;option.textContent=name;Object.entries(attributes).forEach(([key,value])=>option.dataset[key]=value);const createOption=[...select.options].find(item=>item.value==='__new__');select.insertBefore(option,createOption||null);select.value=String(id);};