@extends('layouts.app') @section('title', __('Информация о группе')) {{-- Ports app/Views/group/show.php (legacy, 1450 lines) + the render() payload from App\Controllers\GroupController::show() (app/Controllers/GroupController.php:488-559) — see the Phase 16 plan. Every write form on this page is Laravel-native @csrf as of Phase 21 (edit/delete/deactivate-group: Phase 17; group-tariff CRUD: Phase 18; schedule CRUD: Phase 19; student add/remove: Phase 21, shared with adviser/schedule/index.blade.php since that page migrated in Phase 20). No more legacy CSRF pass-through forms remain on this page. The edit-group modal checks Laravel's own $errors/old() first (set by Illuminate\Http\Request::validate()'s automatic redirect-back), falling back to the legacy $oldInput/$oldErrors (Phase 16) only when Laravel's own bag is empty — the two can never both be populated for the same request/redirect cycle, since only one side ever writes on any given submit. See the Phase 17 plan. Role gating mirrors the legacy view's two in_array($role, ['admin']) blocks exactly (tariffs, financials) — the page itself has no page-level role restriction (only SessionAuth::check()), matching the same flagged-not-fixed ambiguity as student_admin_info.php. The #StudentModal edit-student-in-group form was ported byte-for-byte broken, matching production (it posted to /update_student_to_group.php, a path with no route at all, and its data-weekdays attribute was always empty). It now posts to /adviser/update_student_to_group.php — see that modal's own comment below. --}} @php $editGroupHasError = $errors->any() || isset($oldErrors['group_name']) || isset($oldErrors['teacher_id']) || isset($oldErrors['group_type']) || isset($oldErrors['subject_id']) || isset($oldErrors['language_id']) || isset($oldErrors['learning_type_id']) || isset($oldErrors['class_id']) || isset($oldErrors['is_active']); $editGroupError = fn (string $field) => $errors->first($field) ?: ($oldErrors[$field] ?? null); $editGroupOld = fn (string $field, string $default = '') => $errors->any() ? old($field, $default) : ($oldInput[$field] ?? $default); @endphp @section('content')
@if ($group !== null) {{-- Temporary: switch-over for groups created before generated names (GroupProfileController::renameToFormat()). --}} @if (!empty($renamePreview))
@if ($renamePreview['name'] !== null) {{ __('Новый формат названия:') }} {{ $group->group_name }} → {{ $renamePreview['name'] }} @if ($renamePreview['warning'])
{{ $renamePreview['warning'] }}
@endif @else {{ __('Эту группу пока нельзя переименовать по новому формату: :warning', ['warning' => $renamePreview['warning']]) }} @endif
@if ($renamePreview['name'] !== null)
@csrf
@endif
@endif
{{ __('Общая информация') }}
@can('groups.edit') @endcan @if (\Illuminate\Support\Facades\Gate::any(['groups.edit', 'groups.delete'])) @endif
{{ mb_strtoupper(mb_substr($group->group_name, 0, 2)) }}

{{ $group->group_name }}

@if ((int) $group->is_active !== 1) {{ __('Неактивна') }} @endif
{{ __('Преподаватель') }}
{{ $group->teacher_name ?? '—' }}
{{ __('Тип') }}
{{ $group->type }}
{{ __('Класс') }}
{{ $group->class_name ?? '—' }}
{{ __('Предмет') }}
{{ $group->discipline_name ?? '—' }}
{{ __('Язык') }}
{{ $group->language_name ?? '—' }}
{{ __('Тип обучения') }}
{{ $group->learning_type_name ?? '—' }}
@endif
{{ __('Студенты') }} @can('groups.members.manage') @endcan
{{-- This form used to post to /update_student_to_group.php — a path with no route — and carried neither a CSRF token nor the student/group it was editing, so saving it 404'd and changed nothing. It now posts to the same endpoint the identical modal on /adviser/schedule.php uses, with return_to=group so the confirm screen and the redirect come back here instead of to the adviser schedule. --}}
{{ __('Расписание') }} @can('schedules.edit') {{ __('Подобрать время') }} @endcan
    @if (!empty($localSchedule)) @foreach ($localSchedule as $schedule)
  • {{ __('Время:') }} {{ date('H:i', strtotime($schedule->begin_time)) }} - {{ date('H:i', strtotime($schedule->end_time)) }}
    {{ __('Дни:') }} {{ \App\Support\Weekdays::toString((int) $schedule->weekdays) }}
    {{ __('С:') }} {{ $schedule->begin_date }} @if (!empty($schedule->end_date)) {{ __('по') }} {{ $schedule->end_date }} @endif
    @if (!empty($schedule->classroom_name)) {{ __('Кабинет:') }} {{ $schedule->classroom_name }} {{-- Over its seats (070), counted the way billing and the grid count. --}} @if ($schedule->classroom_capacity !== null && $seatsTaken > (int) $schedule->classroom_capacity) {{ __('учеников :students, мест :seats', ['students' => $seatsTaken, 'seats' => (int) $schedule->classroom_capacity]) }} @endif
    @endif @if (!empty($schedule->classroom_link)) {{ __('Ссылка на кабинет') }} @endif
    @can('schedules.edit')
    @csrf
    @endcan
  • @endforeach @else
    {{ __('Расписание в локальной базе не найдено.') }}
    @endif
@if ($can['group_finances.view'])
{{ __('Финансы группы') }}
@if (!$financials['has_tariff'])
{{ __('Ни у одного ученика группы нет тарифа — выручка не рассчитана.') }}
@endif @if ($financials['student_count'] === 0)
{{ __('В группе нет активных студентов.') }}
@endif
{{ __('За один урок') }}
{{ __('Студентов') }}
{{ $financials['student_count'] }}
{{ __('Выручка') }}
{{ number_format($financials['gross_per_lesson'], 0, '.', ' ') }}
{{ number_format($financials['revenue_per_lesson'], 0, '.', ' ') }} × {{ $financials['student_count'] }}
{{ __('Расходы') }}
{{ number_format($financials['costs_per_lesson'], 0, '.', ' ') }}
{{ __('учитель :teacher_price + аренда :rent_per_lesson', ['teacher_price' => number_format($financials['teacher_price'], 0, '.', ' '), 'rent_per_lesson' => number_format($financials['rent_per_lesson'], 0, '.', ' ')]) }}
{{ __('Прибыль') }}
{{ number_format($financials['profit_per_lesson'], 0, '.', ' ') }}
{{ __('маржа :margin%', ['margin' => $financials['margin']]) }}

{{ __('Текущий месяц') }} {{ __(':lessons_this_month уроков', ['lessons_this_month' => $financials['lessons_this_month']]) }}
{{ __('Начислено') }}
{{ number_format($financials['charged_this_month'], 0, '.', ' ') }}
{{ __('Учитель') }}
{{ number_format($financials['teacher_cost_month'], 0, '.', ' ') }}
{{ __('Аренда') }}
{{ number_format($financials['rent_cost_month'], 0, '.', ' ') }}
{{ __('Прибыль') }}
{{ number_format($financials['profit_this_month'], 0, '.', ' ') }}

{{ __('Прогноз месяца') }} {{ __(':predicted_lessons уроков', ['predicted_lessons' => $financials['predicted_lessons']]) }}
{{ __('Начислено') }}
{{ number_format($financials['predicted_charged'], 0, '.', ' ') }}
{{ __('Учитель') }}
{{ number_format($financials['predicted_teacher_cost'], 0, '.', ' ') }}
{{ __('Аренда') }}
{{ number_format($financials['predicted_rent_cost'], 0, '.', ' ') }}
{{ __('Прибыль') }}
{{ number_format($financials['predicted_profit'], 0, '.', ' ') }}
@endif @if ($journal !== null) @include('groups._journal') @endif
@endsection @push('scripts') {{-- Legacy page loads jQuery itself for the $.ajax student-search autocomplete and $(...).on(...) handlers below — the shared layout doesn't include it. --}} @if (request()->boolean('prefill_schedule')) @php $schedulePrefill = [ 'weekdays' => (int) request()->query('weekdays', 0), 'begin_time' => (string) request()->query('begin_time', ''), 'classroom_id' => (string) request()->query('classroom_id', ''), 'begin_date' => (string) request()->query('begin_date', ''), 'replace' => request()->boolean('replace'), ]; @endphp @endif @endpush