<?php
namespace App\Form;
use App\Entity\Client;
use App\Entity\Site;
use App\Form\Client\BillingInfosType;
use App\Form\Client\FamilyMemberType;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use VictorPrdh\RecaptchaBundle\Form\ReCaptchaType;
class ClientType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
if ($options['isReservation']) {
$builder
->add('civilite', ChoiceType::class, [
'label' => 'Civilité',
'required' => true,
'placeholder' => 'Madame, Monsieur',
'choices' => [
'Madame' => 'Madame',
'Monsieur' => 'Monsieur',
],
])
->add('firstname', TextType::class, [
'label' => 'Prénom',
'attr' => [
'placeholder' => 'Préciser le prénom',
],
'required' => true,
])
->add('lastname', TextType::class, [
'label' => 'Nom',
'attr' => [
'placeholder' => 'Préciser le nom',
],
'required' => true,
])
->add('phone', TextType::class, [
'label' => 'Téléphone',
'attr' => [
'placeholder' => 'Préciser le téléphone',
],
'required' => true
])
->add('email', EmailType::class, [
'label' => 'Email de facturation',
'attr' => [
'placeholder' => 'Email de facturation',
],
'required' => true,
])
->add('roomNumber', TextType::class, [
'label' => 'Numéro de chambre ou d’appartement',
'attr' => [
'placeholder' => 'Numéro de chambre ou d’appartement',
],
'required' => true,
])
->add('prenomTuteur', TextType::class, [
'label' => 'Prénom',
'attr' => [
'placeholder' => 'Préciser le prénom',
],
'required' => false
])
->add('civiliteTuteur', ChoiceType::class, [
'label' => 'Civilité',
'placeholder' => 'Madame, Monsieur',
'choices' => [
'Madame' => 'Madame',
'Monsieur' => 'Monsieur',
],
])
->add('nomTuteur', TextType::class, [
'label' => 'Nom',
'attr' => [
'placeholder' => 'Préciser le nom',
],
'required' => false
])
->add('numeroTuteur', TextType::class, [
'label' => 'Téléphone',
'attr' => [
'placeholder' => 'Préciser le téléphone',
],
'required' => false
])
->add('emailTuteur', TextType::class, [
'label' => 'Email de facturation',
'attr' => [
'placeholder' => "Email de facturation",
],
'required' => false
])
->add('daysOfWeek', ChoiceType::class, [
'label' => 'Jours de préférences (RDV récurrence coiffure)',
'choices' => [
'Lundi' => 'Lundi',
'Mardi' => 'Mardi',
'Mercredi' => 'Mercredi',
'Jeudi' => 'Jeudi',
'Vendredi' => 'Vendredi',
'Samedi' => 'Samedi',
'Dimanche' => 'Dimanche',
],
'multiple' => true,
'expanded' => true, // Optional: set to true for checkboxes, false for a select list
'placeholder' => 'Sélectionner un jour',
'required' => false,
])
// ->add('consignesClient', TextareaType::class, [
// 'label' => 'Consignes client',
// 'attr' => [
// 'placeholder' => "Consignes client",
// ],
// 'required' => false
// ])
->add('cgvAccepted', CheckboxType::class, [
'label' => false,
'required' => false,
])
->add('privacyPolicyAccepted', CheckboxType::class, [
'label' => false,
'required' => false,
])
->add("recaptcha", ReCaptchaType::class);
}
else {
$builder
->add('firstname', TextType::class, [
'label' => 'Prénom',
'attr' => [
'placeholder' => 'Entrer un prénom',
],
'label_attr' => array('class' => ''),
])
->add('site', EntityType::class, [
'label' => 'Site rattaché',
'placeholder' => 'Choisir un site',
'class' => Site::class,
'required' => true,
'query_builder' => function (EntityRepository $repository) {
$qb = $repository->createQueryBuilder('s');
// the function returns a QueryBuilder object
return $qb;
// // find all users where 'deleted' is NOT '1'
// ->where('s.status = :status')
// ->setParameter('status', Site::STATUS_ACTIF);
},
])
->add('lastname', TextType::class, [
'label' => 'Nom',
'attr' => [
'placeholder' => 'Entrer un nom',
],
'label_attr' => array('class' => ''),
])
->add('statusProspect', ChoiceType::class, [
'label' => 'Statut',
'attr' => [
'placeholder' => 'Choisir un statut',
],
'choices' => [
'Prospect' => 'Prospect',
'Actif' => 'Actif',
'Inactif' => 'Inactif',
'Parti' => 'Parti',
'Décès' => 'Décès'
],
'label_attr' => array('class' => ''),
])
// ->add('profilClient', ChoiceType::class, [
// 'label' => 'Profil client',
// 'attr' => [
// 'placeholder' => 'Choisir un profil',
// ],
// 'choices' => [
// 'Autonome et décisionnaire' => 'Autonome et décisionnaire',
// 'Dépendant' => 'Dépendant',
// ],
// 'label_attr' => array('class' => ''),
// ])
->add('civilite', ChoiceType::class, [
'label' => 'Civilite',
'attr' => [
'placeholder' => 'Entrer la civilite',
],
'required' => false,
'placeholder' => 'Choisir une civilite',
'choices' => [
'Madame' => 'Madame',
'Monsieur' => 'Monsieur',
],
'label_attr' => array('class' => ''),
])
// ->add('email', EmailType::class, [
// 'label' => 'Email',
// 'attr' => [
// 'placeholder' => 'Entrer un email',
// ],
// 'required' => false,
// 'label_attr' => array('class' => ''),
// ])
->add('birthday', TextType::class, [
'label' => 'Date de naissance',
'attr' => [
'placeholder' => 'Entrer une date de naissance',
'class' => 'flatpicker'
],
'required' => false,
'label_attr' => array('class' => ''),
])
->add('deathday', TextType::class, [
'label' => 'Date de décès',
'attr' => [
'placeholder' => 'Entrer une date de décès',
'class' => 'flatpicker'
],
'required' => false,
'label_attr' => array('class' => ''),
])
->add('roomNumber', TextType::class, [
'label' => 'Batiment / Étage / Numéro de chambre',
'attr' => [
'placeholder' => 'Entrer le batiment / étage / numéro de chambre',
],
'label_attr' => array('class' => ''),
])
// ->add('phone', TextType::class, [
// 'label' => 'Téléphone client',
// 'attr' => [
// 'placeholder' => 'Entrer un numéro de téléphone',
// ],
// 'label_attr' => array('class' => ''),
// 'required' => false
// ])
// ->add('buildingRoom', TextType::class, [
// 'label' => 'Batiment chambre',
// 'attr' => [
// 'placeholder' => 'Entrer un numéro de batiment',
// ],
// 'label_attr' => array('class' => ''),
// 'required' => false
// ])
// ->add('stairs', TextType::class, [
// 'label' => 'Etage chambre',
// 'attr' => [
// 'placeholder' => 'Entrer un étage de chambre',
// ],
// 'label_attr' => array('class' => ''),
// 'required' => false
// ])
->add('comments', TextareaType::class, [
'label' => 'Commentaires',
'attr' => [
'placeholder' => 'Entrer un commentaire',
],
'label_attr' => array('class' => ''),
'required' => false
])
// contact
->add('nomTuteur', TextType::class, [
'label' => 'Nom contact principal',
'attr' => [
'placeholder' => 'Entrer le nom',
],
'label_attr' => array('class' => ''),
'required' => false
])
->add('consignesClient', TextareaType::class, [
'label' => 'Consignes client',
'attr' => [
'placeholder' => "Consignes client",
],
'required' => false
])
->add('prenomTuteur', TextType::class, [
'label' => 'Prénom contact principal',
'attr' => [
'placeholder' => 'Entrer un prénom',
],
'label_attr' => array('class' => ''),
'required' => false
])
->add('civiliteTuteur', ChoiceType::class, [
'label' => 'Civilite ',
'attr' => [
'placeholder' => 'Entrer la civilite',
],
'choices' => [
'Madame' => 'Madame',
'Monsieur' => 'Monsieur',
],
'label_attr' => array('class' => ''),
])
->add('numeroTuteur', TextType::class, [
'label' => 'Numéro de tel contact principal',
'attr' => [
'placeholder' => 'Entrer un numéro de téléphone',
],
'label_attr' => array('class' => ''),
'required' => false
])
->add('addressTuteur', TextType::class, [
'label' => 'Adresse contact principal',
'attr' => [
'placeholder' => 'Entrer une adresse',
],
'label_attr' => array('class' => ''),
'required' => false
])
->add('addressTuteur2', TextType::class, [
'label' => 'Complément d\'adresse',
'attr' => [
'placeholder' => 'Entrer un complément adresse',
],
'label_attr' => array('class' => ''),
'required' => false
])
->add('city', TextType::class, [
'label' => 'Ville',
'attr' => [
'placeholder' => 'Entrer une ville',
],
'label_attr' => array('class' => ''),
'required' => false
])
->add('zipcode', TextType::class, [
'label' => 'Code postal',
'attr' => [
'placeholder' => 'Entrer un code postal',
],
'label_attr' => array('class' => ''),
'required' => false
])
->add('daysOfWeek', ChoiceType::class, [
'label' => 'Jours de préférences (RDV récurrence coiffure)',
'attr' => [
'class' => 'select2jours'
],
'choices' => [
'Lundi' => 'Lundi',
'Mardi' => 'Mardi',
'Mercredi' => 'Mercredi',
'Jeudi' => 'Jeudi',
'Vendredi' => 'Vendredi',
],
'multiple' => true,
'expanded' => false, // Optional: set to true for checkboxes, false for a select list
'placeholder' => 'Sélectionner un jour',
'required' => false,
])
->add('emailTuteur', TextType::class, [
'label' => 'Email contact principal',
'attr' => [
'placeholder' => 'Entrer un email'
],
'label_attr' => array('class' => ''),
'required' => false
])
->add('commentTuteur', TextareaType::class, [
'label' => 'Qualité contact principal',
'attr' => [
'placeholder' => 'Indiquer la qualité du contact principal (fils, fille, époux, ami...)',
],
'label_attr' => array('class' => ''),
'required' => false
])
->add('nomFacturation', TextType::class, [
'label' => 'Nom contact facturation',
'attr' => [
'placeholder' => 'Entrer le nom',
],
'label_attr' => array('class' => ''),
'required' => false
])
->add('prenomFacturation', TextType::class, [
'label' => 'Prénom contact facturation',
'attr' => [
'placeholder' => 'Entrer le prenom',
],
'label_attr' => array('class' => ''),
'required' => false
])
->add('addressFacturation', TextType::class, [
'label' => 'Adresse facturation',
'attr' => [
'placeholder' => 'Entrer l\'adresse de facturation',
],
'label_attr' => array('class' => ''),
'required' => false
])
->add('ComplementAdresseFacturation', TextType::class, [
'label' => 'Complémenent Adresse facturation',
'attr' => [
'placeholder' => 'Entrer le complément l\'adresse de facturation',
],
'label_attr' => array('class' => ''),
'required' => false
])
->add('codePostalFacturation', TextType::class, [
'label' => 'Code postal Adresse facturation',
'attr' => [
'placeholder' => 'Entrer le code postal de l\'adresse de facturation',
],
'label_attr' => array('class' => ''),
'required' => false
])
->add('villeFacturation', TextType::class, [
'label' => 'Ville Adresse facturation',
'attr' => [
'placeholder' => 'Entrer la ville de l\'adresse de facturation',
],
'label_attr' => array('class' => ''),
'required' => false
])
->add('civiliteFacturation', ChoiceType::class, [
'label' => 'Civilité Facturation',
'required' => true,
'placeholder' => 'Madame, Monsieur',
'choices' => [
'Madame' => 'Madame',
'Monsieur' => 'Monsieur',
],
])
// tab 2 : contract : contrat de prestation
// ->add('contract', CollectionType::class, [
// 'label' => false,
// 'entry_type' => ContractType::class,
// 'entry_options' => ['label' => false],
// 'by_reference' => false,
// 'allow_add' => true,
// 'allow_delete' => true
// ])
->add('billingInfos', BillingInfosType::class, [
'label' => false,
'show_sepa' => $options['show_sepa'],
'defaultCompany' => $options['defaultCompany']
])
// tab 4 : contract : famille
->add('familyMembers', CollectionType::class, [
'label' => false,
'entry_type' => FamilyMemberType::class,
'entry_options' => ['label' => false],
'by_reference' => false,
'allow_add' => true,
'allow_delete' => true
]);
}
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Client::class,
'show_sepa' => false,
'defaultCompany' => null,
'isReservation' => false,
'emailClient' => null,
]);
$resolver->setAllowedTypes('show_sepa', 'bool');
}
}