added API VICON integration for updating admission plans via admin panel (queued).
Updated exams and contests display on programs/show page. Added relevant enums for admission plans.
This commit is contained in:
@@ -22,32 +22,32 @@ class ListAdmissionCampaigns extends ListRecords
|
||||
->action(function () {
|
||||
// Отправляем запрос в фоновом режиме
|
||||
$this->js(<<<JS
|
||||
fetch('/api/get-data', {
|
||||
fetch('/api/get-edu-program-data', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content,
|
||||
},
|
||||
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
.then(() => {
|
||||
// Показываем уведомление об успешном завершении
|
||||
window.dispatchEvent(new CustomEvent('filament-notify', {
|
||||
detail: {
|
||||
type: 'success',
|
||||
title: 'Данные обновлены',
|
||||
body: 'Данные успешно обновлены.',
|
||||
},
|
||||
body: 'Данные успешно обновлены.'
|
||||
}
|
||||
}));
|
||||
})
|
||||
.catch(error => {
|
||||
.catch(() => {
|
||||
// Показываем уведомление об ошибке
|
||||
window.dispatchEvent(new CustomEvent('filament-notify', {
|
||||
detail: {
|
||||
type: 'danger',
|
||||
title: 'Ошибка',
|
||||
body: 'Произошла ошибка при обновлении данных.',
|
||||
},
|
||||
body: 'Произошла ошибка при обновлении данных.'
|
||||
}
|
||||
}));
|
||||
});
|
||||
JS);
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace App\Filament\Resources;
|
||||
use App\Enums\BudgetEducation;
|
||||
use App\Enums\EducationalProgramStatus;
|
||||
use App\Enums\FormEducation;
|
||||
use App\Enums\TypeExam;
|
||||
use App\Filament\Resources\AdmissionPlanResource\Pages;
|
||||
use App\Models\AdmissionCampaign;
|
||||
use App\Models\AdmissionPlan;
|
||||
@@ -82,20 +83,23 @@ class AdmissionPlanResource extends Resource
|
||||
->maxLength(100)
|
||||
->placeholder('Например: Математика')
|
||||
->helperText('Название вступительного испытания'),
|
||||
TextInput::make('priority')
|
||||
->label('Приоритет предмета')
|
||||
->required()
|
||||
->numeric()
|
||||
->columnSpanFull()
|
||||
->maxLength(10),
|
||||
|
||||
Repeater::make('exam')->schema([
|
||||
Select::make('type_exam')
|
||||
Repeater::make('types')->schema([
|
||||
Select::make('type')
|
||||
->label('Тип испытания')
|
||||
->required()
|
||||
->options([
|
||||
'ege' => 'ЕГЭ',
|
||||
'internal_test' => 'Внутреннее испытание',
|
||||
])
|
||||
->options(TypeExam::class)
|
||||
->native(false)
|
||||
->placeholder('Выберите тип')
|
||||
->helperText('Тип вступительного испытания'),
|
||||
|
||||
TextInput::make('min_score')
|
||||
TextInput::make('min_ball')
|
||||
->label('Минимальный балл')
|
||||
->required()
|
||||
->numeric()
|
||||
@@ -134,38 +138,33 @@ class AdmissionPlanResource extends Resource
|
||||
->placeholder('Выберите форму')
|
||||
->columnSpanFull()
|
||||
->helperText('Форма обучения для данной группы'),
|
||||
Section::make()->schema([
|
||||
Select::make('places.form_budget')
|
||||
->label('Форма финансирования')
|
||||
->options(BudgetEducation::class)
|
||||
->required()
|
||||
->native(false)
|
||||
->placeholder('Выберите тип')
|
||||
->helperText('Бюджетные или платные места'),
|
||||
|
||||
Repeater::make('places')
|
||||
->label('Места')
|
||||
->schema([
|
||||
Select::make('form_budget')
|
||||
->label('Форма финансирования')
|
||||
->options(BudgetEducation::class)
|
||||
->required()
|
||||
->native(false)
|
||||
->placeholder('Выберите тип')
|
||||
->helperText('Бюджетные или платные места'),
|
||||
|
||||
TextInput::make('count')
|
||||
->label('Количество мест')
|
||||
->required()
|
||||
->numeric()
|
||||
->minValue(0)
|
||||
->placeholder('Укажите количество')
|
||||
->helperText('Количество доступных мест'),
|
||||
])
|
||||
->columnSpanFull()
|
||||
->maxItems(2)
|
||||
->addActionLabel('Добавить тип мест')
|
||||
TextInput::make('places.count')
|
||||
->label('Количество мест')
|
||||
->required()
|
||||
->numeric()
|
||||
->minValue(0)
|
||||
->placeholder('Укажите количество')
|
||||
->helperText('Количество доступных мест'),
|
||||
]),
|
||||
])
|
||||
->columns(2)
|
||||
->maxItems(3)
|
||||
->maxItems(4) // Adjust if needed based on your actual requirements
|
||||
->collapsible()
|
||||
->collapsed()
|
||||
->addActionLabel('Добавить группу')
|
||||
->helperText('Добавьте группы с условиями поступления');
|
||||
}
|
||||
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
@@ -187,6 +186,9 @@ class AdmissionPlanResource extends Resource
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static function getRelations(): array
|
||||
{
|
||||
return [
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Filament\Resources\AdmissionPlanResource\Pages;
|
||||
|
||||
use App\Filament\Resources\AdmissionPlanResource;
|
||||
use Filament\Actions;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
|
||||
class ListAdmissionPlans extends ListRecords
|
||||
@@ -13,7 +14,52 @@ class ListAdmissionPlans extends ListRecords
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Actions\CreateAction::make(),
|
||||
Actions\CreateAction::make(), // Стандартная кнопка "Создать"
|
||||
Actions\Action::make('fetchData') // Кастомная кнопка
|
||||
->label('Обновить данные')
|
||||
->color('primary') // Цвет кнопки
|
||||
->icon('heroicon-o-arrow-path') // Иконка
|
||||
->action(function () {
|
||||
// Отправляем запрос в фоновом режиме
|
||||
$this->js(<<<JS
|
||||
fetch('/api/get-admission-plans-data', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').content
|
||||
}
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(() => {
|
||||
// Показываем уведомление об успешном завершении
|
||||
window.dispatchEvent(new CustomEvent('filament-notify', {
|
||||
detail: {
|
||||
type: 'success',
|
||||
title: 'Данные обновлены',
|
||||
body: 'Данные успешно обновлены.'
|
||||
}
|
||||
}));
|
||||
})
|
||||
.catch(() => {
|
||||
// Показываем уведомление об ошибке
|
||||
window.dispatchEvent(new CustomEvent('filament-notify', {
|
||||
detail: {
|
||||
type: 'danger',
|
||||
title: 'Ошибка',
|
||||
body: 'Произошла ошибка при обновлении данных.'
|
||||
}
|
||||
}));
|
||||
});
|
||||
JS);
|
||||
|
||||
// Показываем уведомление
|
||||
Notification::make()
|
||||
->title('Данные обновляются')
|
||||
->body('Данные обновляются в фоновом режиме.')
|
||||
->success()
|
||||
->send();
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user