-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
personne ratachée + email reset pass
- Loading branch information
Clément
committed
Nov 3, 2020
1 parent
6797c10
commit 1d7367f
Showing
7 changed files
with
219 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<?php | ||
|
||
namespace App\Admin; | ||
|
||
use ChouetteCoop\PersonnesInteresseesBundle\Entity\Personne; | ||
use Exporter\Source\IteratorCallbackSourceIterator; | ||
use Sonata\AdminBundle\Admin\AbstractAdmin; | ||
use Sonata\AdminBundle\Datagrid\DatagridMapper; | ||
use Sonata\AdminBundle\Datagrid\ListMapper; | ||
use Sonata\AdminBundle\Form\FormMapper; | ||
use Sonata\Form\Type\DatePickerType; | ||
use Sonata\Form\Type\DateRangePickerType; | ||
use Symfony\Component\Form\Extension\Core\Type\TextType; | ||
|
||
class PersonneAdmin extends AbstractAdmin | ||
{ | ||
protected $datagridValues = [ | ||
'_sort_by' => 'nom', | ||
]; | ||
|
||
protected $maxPerPage = 100; | ||
|
||
protected $perPageOptions = array(10, 20, 50, 100, 500, 1000); | ||
|
||
public function toString($object) | ||
{ | ||
return $object instanceof Personne | ||
? $object->getNomAffichage() | ||
: 'Personne intéressée'; | ||
} | ||
|
||
public function getExportFields() | ||
{ | ||
return array('nom', 'prenom', 'email', 'exportDatePremiereReunion'); | ||
} | ||
|
||
public function getDataSourceIterator() | ||
{ | ||
return new IteratorCallbackSourceIterator(parent::getDataSourceIterator(), function($data) { | ||
$data['nom'] = mb_strtoupper($data['nom']); | ||
return $data; | ||
}); | ||
} | ||
|
||
protected function configureFormFields(FormMapper $formMapper) | ||
{ | ||
$formMapper | ||
->with('Civilité', array( | ||
'class' => 'col-md-6', | ||
'description' => ' | ||
Cette section contient les informations principales d’une personne. | ||
<br>Dans un souci d’homogénéïté, merci de <strong>bien veiller à respecter le format proposé</strong> (majuscules, espaces…). | ||
' | ||
)) | ||
->add('nom', null, array( | ||
'attr' => array('placeholder' => 'Tibou') | ||
)) | ||
->add('prenom', null, array( | ||
'label' => 'Prénom', | ||
'attr' => array('placeholder' => 'Jean') | ||
)) | ||
->add('email', null, array( | ||
'attr' => array('placeholder' => 'j.tibou@example.com'), | ||
'help' => "Utilisée pour recontacter cette personne et savoir qu'elle est déjà venue à une réunion si elle nous contacte." | ||
)) | ||
->add('datePremiereReunion', DatePickerType::class, array( | ||
'label' => 'Date de participation à sa première réunion', | ||
'required' => false, | ||
'format' => 'dd/MM/yyyy', | ||
'attr' => array( | ||
'data-date-format' => 'DD/MM/YYYY', | ||
'placeholder' => '15/01/' . date('Y') | ||
) | ||
)) | ||
->end(); | ||
} | ||
|
||
protected function configureDatagridFilters(DatagridMapper $datagridMapper) | ||
{ | ||
$datagridMapper | ||
->add('full_text', 'doctrine_orm_callback', [ | ||
'label' => 'Recherche rapide', | ||
'show_filter' => true, | ||
'callback' => [$this, 'getFullTextFilter'], | ||
'field_type' => TextType::class | ||
]) | ||
->add('datePremiereReunion', 'doctrine_orm_date_range', [ | ||
'label' => 'Date de première réunion' | ||
]) | ||
->add('nom') | ||
->add('prenom', null, [ | ||
'label' => 'Prénom', | ||
]) | ||
->add('email') | ||
; | ||
} | ||
|
||
public function getFullTextFilter($queryBuilder, $alias, $field, $value) | ||
{ | ||
if (!$value['value']) { | ||
return; | ||
} | ||
|
||
$words = array_filter( | ||
array_map('trim', explode(' ', $value['value'])) | ||
); | ||
|
||
foreach ($words as $word) { | ||
// Use `andWhere` instead of `where` to prevent overriding existing `where` conditions | ||
$literal = $queryBuilder->expr()->literal('%' . $word . '%'); | ||
$queryBuilder->andWhere($queryBuilder->expr()->orX( | ||
$queryBuilder->expr()->like($alias.'.nom', $literal), | ||
$queryBuilder->expr()->like($alias.'.prenom', $literal), | ||
$queryBuilder->expr()->like($alias.'.email', $literal) | ||
)); | ||
} | ||
|
||
return true; | ||
} | ||
|
||
protected function configureListFields(ListMapper $listMapper) | ||
{ | ||
$listMapper | ||
->addIdentifier('nom') | ||
->add('prenom', null, array('label' => 'Prénom')) | ||
->addIdentifier('email') | ||
->add('datePremiereReunion', null, array('label' => 'Date de première réunion')) | ||
; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
|
||
namespace App\Controller; | ||
|
||
use Sonata\AdminBundle\Controller\CRUDController; | ||
use Sonata\AdminBundle\Datagrid\ProxyQueryInterface; | ||
use Symfony\Component\HttpFoundation\RedirectResponse; | ||
use Symfony\Component\Security\Core\Exception\AccessDeniedException; | ||
|
||
class UserAdminController extends CRUDController | ||
{ | ||
|
||
public function batchActionImprimeCarte(ProxyQueryInterface $selectedModelQuery) | ||
{ | ||
if (!$this->admin->isGranted('EDIT')) { | ||
throw new AccessDeniedException(); | ||
} | ||
|
||
$modelManager = $this->admin->getModelManager(); | ||
$selectedModels = $selectedModelQuery->execute(); | ||
try { | ||
foreach ($selectedModels as $selectedModel) { | ||
$selectedModel->setCarteImprimee(true); | ||
$modelManager->update($selectedModel); | ||
} | ||
} catch (\Exception $e) { | ||
$this->addFlash('sonata_flash_error', 'Une erreur est survenue'); | ||
|
||
return new RedirectResponse( | ||
$this->admin->generateUrl('list', $this->admin->getFilterParameters()) | ||
); | ||
} | ||
|
||
$this->addFlash('sonata_flash_success', 'Impeccable ! T’es au top, merci…'); | ||
|
||
return new RedirectResponse( | ||
$this->admin->generateUrl('list', $this->admin->getFilterParameters()) | ||
); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% autoescape false %} | ||
Bonjour {{ user }} ! | ||
<br /><br /> | ||
Pour réinitialiser votre mot de passe, merci de vous rendre sur <a href="{{ confirmationUrl }}"> {{ confirmationUrl }}</a> | ||
<br /><br /> | ||
Cordialement,<br /> | ||
L'équipe.<br /> | ||
<p> | ||
<span style="color: red;">POUR VOTRE INFORMATION :</span> pour les Chouettos qui ont un profil Facebook, <i>n'hésitez pas à rejoindre le groupe des Chouettos | ||
sur Facebook !</i> Ce groupe est réservé aux membres de La Chouette Coop pour échanger et fédérer les énergies autour du projet de supermarché coopératif et participatif. | ||
Pour ce faire rendez vous sur <a href="https://www.facebook.com/groups/lesChouettos/">le Facebook les Chouettos</a>. | ||
</p> | ||
<br /> | ||
<img src="https://lachouettecoop.fr/wp-content/uploads/2017/07/bandeauresetting.jpg" /> | ||
{% endautoescape %} |