From a35e7b5f8183259d761fb48961457df51a33da56 Mon Sep 17 00:00:00 2001 From: Baptiste-Moench Date: Mon, 1 Mar 2021 15:03:29 +0100 Subject: [PATCH] =?UTF-8?q?#35:=20Possibilit=C3=A9=20de=20modifier=20un=20?= =?UTF-8?q?utilisateur=20dans=20l'=C3=A9cran=20d'administration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/assets/css/css.css | 7 ++++ src/Controller/AdminController.php | 31 +++++----------- src/Form/EditCustomerType.php | 58 ++++++++++++++++++++++++++++++ templates/admin/profile.html.twig | 55 ++++++++++------------------ 4 files changed, 91 insertions(+), 60 deletions(-) create mode 100644 src/Form/EditCustomerType.php diff --git a/public/assets/css/css.css b/public/assets/css/css.css index f82c487..4d6aec2 100644 --- a/public/assets/css/css.css +++ b/public/assets/css/css.css @@ -118,4 +118,11 @@ h1, h2, h3, h4, h5 { padding: 5px; border-radius:20%; cursor:pointer; +} + +.jumbotron label { + color: #0d6efd; + font-family: Pattaya, sans-serif; + margin-top: 8px; + font-size: 18px; } \ No newline at end of file diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 03917a1..58736ee 100755 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -3,6 +3,7 @@ namespace App\Controller; use App\Entity\HalfDayAdjustment; +use App\Form\EditCustomerType; use App\Form\HalfDayAdjustmentType; use App\Repository\HalfDayAdjustmentRepository; use App\Repository\CheckInRepository; @@ -140,36 +141,20 @@ public function activate($id) */ public function profile($id, Request $request) { - $customer = $this->customerRepository->findOneBy( - [ - 'id' => $id - ] - ); - - $subscription = $this->subscriptionRepository->findOneBy( - [ - 'customer' => $id - ] - ); - - $promo = $this->promoRepository->findOneBy( - [ - 'customer' => $id - ] - ); + $customer = $this->customerRepository->findOneBy(['id' => $id]); + $subscription = $this->subscriptionRepository->findOneBy(['customer' => $id]); + $promo = $this->promoRepository->findOneBy(['customer' => $id]); $counter = $this->createForm(PromoType::class, $promo); $counter->handleRequest($request); - if ($counter->isSubmitted() && $counter->isValid()) { $this->manager->persist($promo); $this->manager->flush(); }; - $status = $this->createForm(CustomerSettingStatusType::class, $customer); - $status->handleRequest($request); - - if ($status->isSubmitted() && $status->isValid()) { + $customerForm = $this->createForm(EditCustomerType::class, $customer); + $customerForm->handleRequest($request); + if ($counter->isSubmitted() && $counter->isValid()) { $this->manager->persist($customer); $this->manager->flush(); } @@ -178,9 +163,9 @@ public function profile($id, Request $request) 'admin/profile.html.twig', [ 'customer' => $customer, + 'customerForm' => $customerForm->createView(), 'subscription' => $subscription, 'formPromo' => $counter->createView(), - 'formStatus' => $status->createView() ] ); } diff --git a/src/Form/EditCustomerType.php b/src/Form/EditCustomerType.php new file mode 100644 index 0000000..4fc8f83 --- /dev/null +++ b/src/Form/EditCustomerType.php @@ -0,0 +1,58 @@ +add('lastname', TextType::class, [ + 'label' => 'Nom' + ]) + ->add('firstname', TextType::class, [ + 'label' => 'Prénom' + ]) + ->add('society', TextType::class, [ + 'label' => 'Société (facultatif)', + 'required' => false + ]) + ->add('country', TextType::class, [ + 'label' => 'Pays' + ]) + ->add('address', TextType::class, [ + 'label' => 'Adresse' + ]) + ->add('city', TextType::class, [ + 'label' => 'Ville' + ]) + ->add('zip', TextType::class, [ + 'label' => 'Code postal' + ]) + ->add('phone', TextType::class, [ + 'label' => 'Téléphone' + ]) + ->add('mail', EmailType::class, [ + 'label' => 'E-mail' + ]) + ->add('status', TextType::class, [ + 'label' => 'Statut' + ]) + ; + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => Customer::class, + ]); + } +} diff --git a/templates/admin/profile.html.twig b/templates/admin/profile.html.twig index 80ab2b1..49fe795 100644 --- a/templates/admin/profile.html.twig +++ b/templates/admin/profile.html.twig @@ -10,36 +10,25 @@
-
-
-

Nom :

-

{{ customer.lastname }}

-

Prénom :

-

{{ customer.firstname }}

-

Téléphone :

-

{{ customer.phone }}

-

E-mail :

-

{{ customer.mail }}

- {% if customer.society != '' %} -

Société :

-

{{ customer.society }}

- {% endif %} + {{ form_start(customerForm) }} +
+
+ {{ form_row(customerForm.lastname) }} + {{ form_row(customerForm.firstname) }} + {{ form_row(customerForm.phone) }} + {{ form_row(customerForm.mail) }} + {{ form_row(customerForm.society) }} +
+
+ {{ form_row(customerForm.country) }} + {{ form_row(customerForm.address) }} + {{ form_row(customerForm.zip) }} + {{ form_row(customerForm.city) }} + {{ form_row(customerForm.status) }} +
-
-

Pays :

-

{{ customer.country }}

-

Adresse :

-

{{ customer.address }}

-

Code postal :

-

{{ customer.zip }}

-

Ville :

-

{{ customer.city }}

-

Statut :

-

- {{ customer.getStatus }} -

-
-
+ + {{ form_end(customerForm) }}
@@ -50,14 +39,6 @@ {{ form_end(formPromo) }}
-
-
- {{ form_start(formStatus) }} -

Statut :

- {{ form_row(formStatus.status, {'label':false, 'attr': {'class': 'col-4 offset-4'}}) }} - - {{ form_end(formStatus) }} -