2025-10-22 17:09:48 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Filament\Resources\Members\Schemas;
|
|
|
|
|
|
2026-01-18 14:35:41 +01:00
|
|
|
use App\Enums\IspconfigType;
|
2025-10-22 17:09:48 +02:00
|
|
|
use App\Models\Member;
|
|
|
|
|
use Filament\Actions\Action;
|
|
|
|
|
use Filament\Forms\Components\DatePicker;
|
|
|
|
|
use Filament\Forms\Components\Select;
|
2026-02-03 10:53:23 +01:00
|
|
|
use Filament\Infolists\Components\ViewEntry;
|
2026-01-30 15:27:23 +01:00
|
|
|
use Filament\Schemas\Components\Tabs;
|
|
|
|
|
use Filament\Schemas\Components\Tabs\Tab;
|
2025-10-22 17:09:48 +02:00
|
|
|
use Filament\Forms\Components\TextInput;
|
|
|
|
|
use Filament\Forms\Components\Toggle;
|
|
|
|
|
use Filament\Schemas\Components\Grid;
|
|
|
|
|
use Filament\Schemas\Components\Section;
|
|
|
|
|
use Filament\Schemas\Schema;
|
2026-01-18 14:35:41 +01:00
|
|
|
use Filament\Infolists\Components\RepeatableEntry;
|
2026-01-30 15:27:23 +01:00
|
|
|
use Filament\Infolists\Components\TextEntry;
|
2026-02-03 10:53:23 +01:00
|
|
|
use Filament\Support\Icons\Heroicon;
|
|
|
|
|
use App\Filament\Actions\ServiceToggleAction;
|
2025-10-22 17:09:48 +02:00
|
|
|
|
|
|
|
|
class MemberForm
|
|
|
|
|
{
|
|
|
|
|
public static function configure(Schema $schema): Schema
|
|
|
|
|
{
|
|
|
|
|
return $schema
|
|
|
|
|
->components([
|
|
|
|
|
Grid::make()
|
|
|
|
|
->schema([
|
2026-01-30 15:27:23 +01:00
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Colonne principale
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
2025-10-22 17:09:48 +02:00
|
|
|
Grid::make(1)
|
|
|
|
|
->schema([
|
2026-01-30 15:27:23 +01:00
|
|
|
Tabs::make('MemberTabs')
|
|
|
|
|
->tabs([
|
|
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| TAB : Informations générales
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
Tabs\Tab::make('Informations générales')
|
2026-02-03 10:53:23 +01:00
|
|
|
->icon(Heroicon::OutlinedInformationCircle)
|
2026-01-30 15:27:23 +01:00
|
|
|
->schema([
|
|
|
|
|
Section::make('Informations personnelles')
|
|
|
|
|
->collapsible()
|
|
|
|
|
->schema([
|
|
|
|
|
TextInput::make('lastname')
|
|
|
|
|
->label(Member::getAttributeLabel('lastname'))
|
|
|
|
|
->required(),
|
|
|
|
|
|
|
|
|
|
TextInput::make('firstname')
|
|
|
|
|
->label(Member::getAttributeLabel('firstname'))
|
|
|
|
|
->required(),
|
|
|
|
|
|
|
|
|
|
DatePicker::make('date_of_birth')
|
|
|
|
|
->label(Member::getAttributeLabel('date_of_birth')),
|
|
|
|
|
|
|
|
|
|
TextInput::make('company')
|
|
|
|
|
->label(Member::getAttributeLabel('company')),
|
|
|
|
|
])
|
|
|
|
|
->columns(2),
|
|
|
|
|
|
|
|
|
|
Section::make('Informations administratives')
|
|
|
|
|
->collapsible()
|
|
|
|
|
->schema([
|
|
|
|
|
TextInput::make('keycloak_id')
|
|
|
|
|
->label(Member::getAttributeLabel('keycloak_id')),
|
|
|
|
|
|
|
|
|
|
Select::make('nature')
|
|
|
|
|
->label(Member::getAttributeLabel('nature'))
|
|
|
|
|
->options([
|
|
|
|
|
'physical' => Member::getAttributeLabel('physical'),
|
|
|
|
|
'legal' => Member::getAttributeLabel('legal'),
|
|
|
|
|
])
|
|
|
|
|
->default('physical')
|
|
|
|
|
->required(),
|
|
|
|
|
|
|
|
|
|
Select::make('group_id')
|
|
|
|
|
->label(Member::getAttributeLabel('group_id'))
|
|
|
|
|
->relationship('group', 'name')
|
|
|
|
|
->default(null),
|
|
|
|
|
])
|
|
|
|
|
->columns(2),
|
|
|
|
|
|
|
|
|
|
Section::make('Coordonnées')
|
|
|
|
|
->collapsible()
|
|
|
|
|
->schema([
|
|
|
|
|
TextInput::make('email')
|
|
|
|
|
->label(Member::getAttributeLabel('email'))
|
|
|
|
|
->email()
|
|
|
|
|
->required(),
|
|
|
|
|
|
|
|
|
|
TextInput::make('phone1')
|
|
|
|
|
->label(Member::getAttributeLabel('phone1'))
|
|
|
|
|
->tel(),
|
|
|
|
|
|
|
|
|
|
TextInput::make('phone2')
|
|
|
|
|
->label(Member::getAttributeLabel('phone2'))
|
|
|
|
|
->tel(),
|
|
|
|
|
|
|
|
|
|
TextInput::make('address')
|
|
|
|
|
->label(Member::getAttributeLabel('address')),
|
|
|
|
|
|
|
|
|
|
TextInput::make('zipcode')
|
|
|
|
|
->label(Member::getAttributeLabel('zipcode')),
|
|
|
|
|
|
|
|
|
|
TextInput::make('city')
|
|
|
|
|
->label(Member::getAttributeLabel('city')),
|
|
|
|
|
|
|
|
|
|
TextInput::make('country')
|
|
|
|
|
->label(Member::getAttributeLabel('country')),
|
|
|
|
|
])
|
|
|
|
|
->columns(2),
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| TAB : Services/Modules
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
Tabs\Tab::make('Modules')
|
2026-02-03 10:53:23 +01:00
|
|
|
->icon(Heroicon::OutlinedPuzzlePiece)
|
2026-01-30 15:27:23 +01:00
|
|
|
->schema([
|
|
|
|
|
/*
|
|
|
|
|
| Messageries ISPConfig (lecture seule)
|
|
|
|
|
*/
|
|
|
|
|
Section::make('Messagerie ISPConfig')
|
2026-02-03 10:53:23 +01:00
|
|
|
->afterHeader([
|
|
|
|
|
ServiceToggleAction::forService('mail'),
|
|
|
|
|
])
|
2026-01-30 15:27:23 +01:00
|
|
|
->collapsible()
|
|
|
|
|
->schema([
|
|
|
|
|
RepeatableEntry::make('ispconfig_mails')
|
2026-02-03 10:53:23 +01:00
|
|
|
->label('Données ISPConfig Mail')
|
2026-01-30 15:27:23 +01:00
|
|
|
->state(fn(?Member $record) => $record?->ispconfigs()
|
|
|
|
|
->where('type', IspconfigType::MAIL)
|
|
|
|
|
->get()
|
|
|
|
|
)
|
|
|
|
|
->schema([
|
|
|
|
|
TextEntry::make('email')
|
|
|
|
|
->label('Adresse email'),
|
|
|
|
|
|
|
|
|
|
TextEntry::make('ispconfig_service_user_id')
|
|
|
|
|
->label('ID ISPConfig'),
|
|
|
|
|
|
|
|
|
|
TextEntry::make('data.mailuser.quota')
|
2026-02-03 10:53:23 +01:00
|
|
|
->label('Quota'),
|
|
|
|
|
//->formatStateUsing(fn($state) => $state ? "{$state} Mo" : 'Non défini'
|
|
|
|
|
//),
|
2026-01-30 15:27:23 +01:00
|
|
|
|
|
|
|
|
TextEntry::make('data.mailuser.domain')
|
|
|
|
|
->label('Domaine')
|
|
|
|
|
->default('retzien.fr'),
|
2026-02-03 10:53:23 +01:00
|
|
|
ViewEntry::make('data')
|
|
|
|
|
->label('JSON')
|
|
|
|
|
->view('filament.components.json-viewer')
|
|
|
|
|
->viewData(fn($state) => [
|
|
|
|
|
'data' => $state,
|
|
|
|
|
])
|
|
|
|
|
->columnSpanFull(),
|
2026-01-30 15:27:23 +01:00
|
|
|
])
|
|
|
|
|
->columns(2),
|
|
|
|
|
])
|
|
|
|
|
->visible(fn(?Member $record) => $record?->ispconfigs()
|
|
|
|
|
->where('type', IspconfigType::MAIL)
|
|
|
|
|
->exists()
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
| Hébergements web ISPConfig
|
|
|
|
|
*/
|
2026-02-03 10:53:23 +01:00
|
|
|
Section::make('Hébergements Web')
|
|
|
|
|
->afterHeader([
|
|
|
|
|
ServiceToggleAction::forService('webhosting'),
|
|
|
|
|
])
|
2026-01-30 15:27:23 +01:00
|
|
|
->collapsible()
|
|
|
|
|
->schema([
|
|
|
|
|
RepeatableEntry::make('ispconfigs_web')
|
2026-02-03 10:53:23 +01:00
|
|
|
->label('Données ISPConfig Web')
|
2026-01-30 15:27:23 +01:00
|
|
|
->state(fn(?Member $record) => $record?->ispconfigs()
|
|
|
|
|
->where('type', IspconfigType::WEB)
|
|
|
|
|
->get()
|
2026-02-03 10:53:23 +01:00
|
|
|
->map(fn($ispconfig) => $ispconfig->toArray())
|
2026-01-30 16:39:47 +01:00
|
|
|
->all()
|
2026-01-30 15:27:23 +01:00
|
|
|
)
|
|
|
|
|
->schema([
|
2026-01-30 16:39:47 +01:00
|
|
|
TextEntry::make('data.domain_id')
|
2026-02-03 10:53:23 +01:00
|
|
|
->label('ID ISPConfig'),
|
|
|
|
|
|
2026-01-30 16:39:47 +01:00
|
|
|
TextEntry::make('data.domain')
|
2026-01-30 15:27:23 +01:00
|
|
|
->label('Domaine'),
|
2026-02-03 10:53:23 +01:00
|
|
|
|
2026-01-30 16:39:47 +01:00
|
|
|
TextEntry::make('data.active')
|
|
|
|
|
->label('État')
|
2026-02-03 10:53:23 +01:00
|
|
|
->formatStateUsing(fn($state) => $state === 'y' ? 'Activé' : 'Désactivé'
|
2026-01-30 15:27:23 +01:00
|
|
|
),
|
2026-02-03 10:53:23 +01:00
|
|
|
ViewEntry::make('data')
|
|
|
|
|
->label('JSON')
|
|
|
|
|
->view('filament.components.json-viewer')
|
|
|
|
|
->viewData(fn($state) => [
|
|
|
|
|
'data' => $state,
|
|
|
|
|
])
|
|
|
|
|
->columnSpanFull(),
|
|
|
|
|
// @todo: background color : #F5F8FA
|
2026-01-30 15:27:23 +01:00
|
|
|
])
|
2026-02-03 10:53:23 +01:00
|
|
|
->columns(3),
|
|
|
|
|
|
2026-01-30 15:27:23 +01:00
|
|
|
])
|
|
|
|
|
->visible(fn(?Member $record) => $record?->ispconfigs()
|
2026-01-18 14:35:41 +01:00
|
|
|
->where('type', IspconfigType::WEB)
|
2026-01-30 15:27:23 +01:00
|
|
|
->exists()
|
2026-02-03 10:53:23 +01:00
|
|
|
),
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
| Compte(s) NextCloud (lecture seule)
|
|
|
|
|
*/
|
|
|
|
|
Section::make('NextCloud')
|
|
|
|
|
->afterHeader([
|
|
|
|
|
ServiceToggleAction::forService('nextcloud'),
|
|
|
|
|
])
|
2026-01-30 16:39:47 +01:00
|
|
|
->collapsible()
|
|
|
|
|
->schema([
|
2026-02-03 10:53:23 +01:00
|
|
|
RepeatableEntry::make('nextcloud_accounts')
|
|
|
|
|
->label('Données NextCloud')
|
|
|
|
|
->state(fn(?Member $record) => $record?->nextcloudAccounts()
|
|
|
|
|
->get()
|
|
|
|
|
->map(fn($nextcloudAccount) => $nextcloudAccount->toArray())
|
|
|
|
|
->all()
|
|
|
|
|
)
|
|
|
|
|
->schema([
|
|
|
|
|
TextEntry::make('nextcloud_user_id')
|
|
|
|
|
->label('Id Nextcloud'),
|
|
|
|
|
|
|
|
|
|
TextEntry::make('data.displayname')
|
|
|
|
|
->label('Nom de l\'utilisateur'),
|
|
|
|
|
|
|
|
|
|
TextEntry::make('data.enabled')
|
|
|
|
|
->label('État')
|
|
|
|
|
->formatStateUsing(fn($state) => $state == 'true' ? 'Activé' : 'Désactivé'
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
ViewEntry::make('data')
|
|
|
|
|
->label('JSON')
|
|
|
|
|
->view('filament.components.json-viewer')
|
|
|
|
|
->viewData(fn($state) => [
|
|
|
|
|
'data' => $state,
|
|
|
|
|
])
|
|
|
|
|
->columnSpanFull(),
|
|
|
|
|
])
|
|
|
|
|
->columns(3),
|
2026-01-30 16:39:47 +01:00
|
|
|
])
|
2026-02-03 10:53:23 +01:00
|
|
|
->visible(fn(?Member $record) => $record?->nextcloudAccounts()
|
2026-01-30 16:39:47 +01:00
|
|
|
->exists()
|
2026-01-30 15:27:23 +01:00
|
|
|
),
|
|
|
|
|
]),
|
2026-02-03 10:53:23 +01:00
|
|
|
])
|
|
|
|
|
->contained(false)
|
2025-10-22 17:09:48 +02:00
|
|
|
])
|
|
|
|
|
->columnSpan(3),
|
2026-01-30 15:27:23 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
| Colonne latérale
|
|
|
|
|
|--------------------------------------------------------------------------
|
|
|
|
|
*/
|
2025-10-22 17:09:48 +02:00
|
|
|
Grid::make(1)
|
|
|
|
|
->schema([
|
|
|
|
|
Section::make('Statut')
|
2026-01-30 15:27:23 +01:00
|
|
|
->collapsible()
|
2025-10-22 17:09:48 +02:00
|
|
|
->schema([
|
|
|
|
|
Select::make('status')
|
|
|
|
|
->label(Member::getAttributeLabel('status'))
|
|
|
|
|
->options([
|
|
|
|
|
'draft' => Member::getAttributeLabel('draft'),
|
|
|
|
|
'valid' => Member::getAttributeLabel('valid'),
|
|
|
|
|
'pending' => Member::getAttributeLabel('pending'),
|
|
|
|
|
'cancelled' => Member::getAttributeLabel('cancelled'),
|
|
|
|
|
'excluded' => Member::getAttributeLabel('excluded'),
|
|
|
|
|
])
|
|
|
|
|
->default('draft')
|
|
|
|
|
->required(),
|
|
|
|
|
|
|
|
|
|
Toggle::make('public_membership')
|
|
|
|
|
->label(Member::getAttributeLabel('public_membership'))
|
|
|
|
|
->required(),
|
|
|
|
|
])
|
|
|
|
|
->extraAttributes(['class' => 'sticky top-4 h-fit']),
|
2026-01-30 15:27:23 +01:00
|
|
|
|
2025-10-22 17:09:48 +02:00
|
|
|
Section::make('Actions')
|
2026-01-30 15:27:23 +01:00
|
|
|
->collapsible()
|
2025-10-22 17:09:48 +02:00
|
|
|
->schema([
|
|
|
|
|
Action::make('send-payment-mail')
|
|
|
|
|
->label('Envoyer le mail de paiement')
|
|
|
|
|
->icon('heroicon-o-envelope')
|
2026-01-30 15:27:23 +01:00
|
|
|
->action(function () {
|
|
|
|
|
// Mail de paiement pour nouvelle inscription (Job)
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
Action::make('send-renewal-mail')
|
2025-10-22 17:09:48 +02:00
|
|
|
->label('Envoyer un mail de relance')
|
2026-01-30 15:27:23 +01:00
|
|
|
->icon('heroicon-o-envelope')
|
|
|
|
|
->action(function () {
|
|
|
|
|
// Mail de relance à créer (Job)
|
|
|
|
|
}),
|
2025-10-22 17:09:48 +02:00
|
|
|
])
|
2026-01-30 15:27:23 +01:00
|
|
|
->extraAttributes(['class' => 'sticky top-4 h-fit']),
|
2025-10-22 17:09:48 +02:00
|
|
|
])
|
|
|
|
|
->columnSpan(1),
|
|
|
|
|
])
|
|
|
|
|
->columns(4)
|
|
|
|
|
->columnSpanFull(),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
}
|