Skip to content

Commit

Permalink
feat: personne rattachée
Browse files Browse the repository at this point in the history
  • Loading branch information
Clément committed Nov 4, 2020
1 parent 1d7367f commit be5444a
Show file tree
Hide file tree
Showing 10 changed files with 613 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
/vendor/
.idea
###< symfony/framework-bundle ###
/public/uploads/
36 changes: 35 additions & 1 deletion config/packages/sonata_admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,41 @@ sonata_admin:

dashboard:
blocks:
- { type: sonata.admin.block.admin_list, position: left }
- { type: sonata.admin.block.admin_list, position: right }
- { type: sonata.block.service.text, position: left, settings: { content: "<h2>Bienvenue dans Admin Chouettos !</h2>

<h3>Admin Chouettos est l’annuaire des Chouettos.</h3>
<p>
Il permet d’autoriser l’accès aux outils de La Chouette Coop (passage en caisse, espace membres, …) à un·e Chouettos.
</p>
<p>
Pour celà : sa fiche doit être créée dans Admin Chouettos,
<strong>ET</strong> sa fiche doit être activée (en cochant la case « Membre ? »).
</p>
<p>
Admin Chouettos permet également de stocker les données recueillies pour chaque Chouettos ou personne
s'étant déclarée intéréssée par le projet (lors d'une réunion d'acceuil par exemple).
</p>

<h3>Quand et pour quelle opération utiliser Admin Chouettos ?</h3>
<ul>
<li>
Lors d’une nouvelle adhésion :
création de la fiche du Chouettos (nouvel adhérent)
</li>
<li>
Lors d’un renouvellement d’adhésion :
ajout d’une adhésion sur la fiche et modifications éventuelles de certaines données (ex: adresse)
</li>
<li>
Lorsqu’on recueille de nouvelles informations sur un Chouettos (date de naissance, nouvelle adresse...) :
modification de la fiche
</li>
<li>
Lorsqu’une adhésion devient effective (adhésion à l’année en cours faite en fin d’année précédente) :
activation de la fiche
</li>
</ul>"} }
templates:
layout: 'standard_layout.html.twig'
options:
Expand Down
7 changes: 7 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,10 @@ services:
- ~
calls:
- [ setTranslationDomain, [ GlukoseAdminContactBundle ] ]

admin.personne_rattachee:
class: App\Admin\PersonneRattacheeAdmin
arguments: [~, App\Entity\PersonneRattachee, ~]
tags:
- { name: sonata.admin, manager_type: orm, group: admin, label: PersonneRattachee }
public: true
32 changes: 32 additions & 0 deletions migrations/Version20201104092500.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20201104092500 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}

public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE personne_rattachee (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, nom VARCHAR(255) NOT NULL, prenom VARCHAR(255) NOT NULL, photo VARCHAR(255) NOT NULL, date_de_naissance DATE DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, telephone VARCHAR(255) DEFAULT NULL, updated DATETIME DEFAULT NULL, INDEX IDX_44AB1594A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE personne_rattachee ADD CONSTRAINT FK_44AB1594A76ED395 FOREIGN KEY (user_id) REFERENCES fos_user (id)');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE personne_rattachee');
}
}
31 changes: 31 additions & 0 deletions migrations/Version20201104093109.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20201104093109 extends AbstractMigration
{
public function getDescription() : string
{
return '';
}

public function up(Schema $schema) : void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE personne_rattachee CHANGE photo photo VARCHAR(255) DEFAULT NULL');
}

public function down(Schema $schema) : void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE personne_rattachee CHANGE photo photo VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`');
}
}
108 changes: 108 additions & 0 deletions src/Admin/PersonneRattacheeAdmin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<?php

declare(strict_types=1);

namespace App\Admin;

use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\Form\Type\DatePickerType;
use Symfony\Component\Form\Extension\Core\Type\FileType;

final class PersonneRattacheeAdmin extends AbstractAdmin
{

public function preUpdate($user)
{
$this->manageFileUpload($user);
}
public function prePersist($user)
{
$this->manageFileUpload($user);
}
private function manageFileUpload($user) {
if ($user->getFile()) {
$user->refreshUpdated();
}
}

protected function configureFormFields(FormMapper $formMapper): void
{
$user = $this->getSubject();

$fileFieldOptions = array('required' => false);
if ($user && ($webPath = $user->getPhoto())) {
$fileFieldOptions['help'] = '<img src="uploads/documents/'.$webPath.'" class="admin-preview" style="width: 300px;" />';
}

$formMapper
->with('Informations', array(
'class' => 'col-md-6'
))

->add('nom')
->add('prenom')
->add('dateDeNaissance', DatePickerType::class, array(
'label' => 'Date de naissance',
'required' => false,
'format' => 'dd/MM/yyyy',
'attr' => array(
'data-date-format' => 'DD/MM/YYYY',
'placeholder' => '31/01/1970'
)
))
->add('email')
->add('telephone')
->end()
->with('Photo', array(
'class' => 'col-md-6'
))
->add('file', FileType::class, $fileFieldOptions)
->end()
;
}

protected function configureDatagridFilters(DatagridMapper $datagridMapper): void
{
$datagridMapper
->add('id')
->add('nom')
->add('prenom')
->add('photo')
->add('dateDeNaissance')
->add('email')
->add('telephone')
;
}

protected function configureListFields(ListMapper $listMapper): void
{
$listMapper
->addIdentifier('id')
->addIdentifier('nom')
->add('prenom')
->add('photo')
->add('dateDeNaissance')
->add('email')
->add('telephone');
}



protected function configureShowFields(ShowMapper $showMapper): void
{
$showMapper
->add('id')
->add('nom')
->add('prenom')
->add('photo')
->add('dateDeNaissance')
->add('email')
->add('telephone')
->add('updated')
;
}
}
20 changes: 18 additions & 2 deletions src/Admin/UserAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function preUpdate($user)
$this->syncRelations($user);
$em = $this->getModelManager()->getEntityManager($this->getClass());
$this->originalUserData = $em->getUnitOfWork()->getOriginalEntityData($user);
//$this->manageFileUpload($user);
$this->manageFileUpload($user);
}

public function syncRelations($user)
Expand Down Expand Up @@ -182,7 +182,7 @@ protected function configureFormFields(FormMapper $formMapper)

$fileFieldOptions = array('required' => false);
if ($user && ($webPath = $user->getPhoto())) {
$fileFieldOptions['help'] = '<img src="/uploads/'.$webPath.'" class="admin-preview" style="width: 300px;" />';
$fileFieldOptions['help'] = '<img src="uploads/documents/'.$webPath.'" class="admin-preview" style="width: 300px;" />';
}

$formMapper
Expand Down Expand Up @@ -277,6 +277,22 @@ protected function configureFormFields(FormMapper $formMapper)
)
)
->end()
->with('Personne Ratachée', array(
'class' => 'col-md-12',
'description' => ''
))
->add(
'personneRattachee',
CollectionType::class,
array(
'required' => false,
),
array(
'edit' => 'inline',
'inline' => 'table',
)
)
->end()

->with('Paiements des parts sociales', array(
'class' => 'col-md-12',
Expand Down
Loading

0 comments on commit be5444a

Please sign in to comment.