diff --git a/app/Resources/views/admin/members/general_meeting/list.html.twig b/app/Resources/views/admin/members/general_meeting/list.html.twig
index 785c83878..b2faa53ae 100644
--- a/app/Resources/views/admin/members/general_meeting/list.html.twig
+++ b/app/Resources/views/admin/members/general_meeting/list.html.twig
@@ -10,6 +10,12 @@
Préparer une assemblée générale
+
+
+
+ Liste des comptes rendus
+
+
{% if latestDate %}
diff --git a/app/Resources/views/admin/members/general_meeting/reports.html.twig b/app/Resources/views/admin/members/general_meeting/reports.html.twig
new file mode 100644
index 000000000..d7e5a0538
--- /dev/null
+++ b/app/Resources/views/admin/members/general_meeting/reports.html.twig
@@ -0,0 +1,69 @@
+{% extends 'admin/base_with_header.html.twig' %}
+
+{% block content %}
+
Assemblée générale - Comptes rendus
+
+
+
+
+ {{ form_start(form) }}
+
+ {{ form_end(form) }}
+
+
+
+ - Fichiers PDF uniquement
+ - Format de nommage :
YYYY-MM-JJ_CR AG AFUP YYYY-YYYY.pdf
+ Exemple : 2014-02-15_CR AG AFUP 2013-2014.pdf
+
+
+
+
+
+
+
+
+
+
+ Nom |
+ Type |
+ Poids |
+ Date |
+ |
+
+
+
+ {% for report in reports %}
+
+ {{ report.filename }} |
+
+ {{ report.extension }}
+ |
+
+ {{ report.size }}
+ |
+
+ {{ report.mtime|date('d/m/y H:i') }}
+ |
+
+
+
+
+ |
+
+ {% endfor %}
+
+
+{% endblock %}
diff --git a/app/config/config.yml b/app/config/config.yml
index 4841e5c87..5d2572e69 100644
--- a/app/config/config.yml
+++ b/app/config/config.yml
@@ -60,6 +60,7 @@ parameters:
- admin_members_general_meeting
- admin_members_general_meeting_prepare
- admin_members_general_meeting_edit
+ - admin_members_general_meeting_reports
assemblee_generale_votes:
nom: 'Assemblée générale - votes'
niveau: 'ROLE_ADMIN'
diff --git a/app/config/routing/admin.yml b/app/config/routing/admin.yml
index 4ed7243fa..19c0baed8 100644
--- a/app/config/routing/admin.yml
+++ b/app/config/routing/admin.yml
@@ -97,6 +97,10 @@ admin_members_general_vote_close:
path: /members/general_meeting_vote/close
defaults: {_controller: AppBundle\Controller\Admin\Members\GeneralMeetingVote\CloseAction}
+admin_members_general_meeting_reports:
+ path: /members/general_meeting/reports
+ defaults: {_controller: AppBundle\Controller\Admin\Members\GeneralMeeting\ReportsAction}
+
admin_techletter:
resource: "techletter_admin.yml"
prefix: /techletter
diff --git a/db/seeds/GeneralMeetings.php b/db/seeds/GeneralMeetings.php
index 9894ffdaf..349db289e 100644
--- a/db/seeds/GeneralMeetings.php
+++ b/db/seeds/GeneralMeetings.php
@@ -6,6 +6,15 @@ class GeneralMeetings extends AbstractSeed
{
public function run()
{
+ $dir = 'htdocs/uploads/general_meetings_reports/';
+ if (!is_dir($dir)) {
+ if (!mkdir($dir) && !is_dir($dir)) {
+ throw new \RuntimeException(sprintf('Directory "%s" was not created', $dir));
+ }
+ }
+ copy('tests/behat/files/test_file1.pdf', $dir.'2014-02-15_CR AG AFUP 2013-2014.pdf');
+ copy('tests/behat/files/test_file2.pdf', $dir.'2013-01-30_CR AG AFUP 2012-2013.pdf');
+
$timestamp = strtotime(date("Y-m-d") . "+2 months");
// Assemblées générales
diff --git a/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ReportsAction.php b/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ReportsAction.php
new file mode 100644
index 000000000..7571e74cc
--- /dev/null
+++ b/sources/AppBundle/Controller/Admin/Members/GeneralMeeting/ReportsAction.php
@@ -0,0 +1,117 @@
+twig = $twig;
+ $this->flashBag = $flashBag;
+ $this->urlGenerator = $urlGenerator;
+ $this->formFactory = $formFactory;
+ }
+
+ public function __invoke(Request $request): Response
+ {
+ $basePath = 'uploads/general_meetings_reports/';
+
+ // delete
+ if ($fileToDelete = $request->query->get('file')) {
+ $fileToDelete = $basePath . basename($fileToDelete);
+ if (is_file($fileToDelete) && unlink($fileToDelete)) {
+ $this->flashBag->add('notice', 'Le compte rendu a correctement été supprimé.');
+ } else {
+ $this->flashBag->add('error', 'Le compte rendu n\'a pas été supprimé.');
+ }
+ return new RedirectResponse($this->urlGenerator->generate($request->attributes->get('_route')));
+ }
+
+ // add
+ $form = $this->buildForm();
+ if ($form->handleRequest($request) && $form->isValid()) {
+ /** @var UploadedFile $uploadedFile */
+ $reportFile = $form->get('file')->getData();
+ if ($reportFile->move($basePath, $reportFile->getClientOriginalName())) {
+ $this->flashBag->add('notice', 'Le compte rendu a correctement été ajouté.');
+ } else {
+ $this->flashBag->add('error', 'Le compte rendu n\'a pas été ajouté.');
+ }
+ return new RedirectResponse($this->urlGenerator->generate($request->attributes->get('_route')));
+ }
+
+ $files = glob($basePath . '*.pdf');
+ rsort($files);
+
+ $reports = [];
+ foreach ($files as $file) {
+ $report = pathinfo($file);
+
+ $report['size'] = self::humanFilesize(filesize($file));
+ $report['mtime'] = filemtime($file);
+ $reports[] = $report;
+ }
+
+ return new Response($this->twig->render('admin/members/general_meeting/reports.html.twig', [
+ 'form' => $form->createView(),
+ 'reports' => $reports
+ ]));
+ }
+
+ private static function humanFilesize($bytes): string
+ {
+ $sz = 'BKMGTP';
+ $factor = floor((strlen($bytes) - 1) / 3);
+
+ return sprintf("%.2f", $bytes / (1024 ** $factor)) . $sz[(int) $factor];
+ }
+
+ private function buildForm(): FormInterface
+ {
+ return $this->formFactory->createNamed('report')
+ ->add('file', FileType::class, [
+ 'label' => 'Fichier',
+ 'required' => true,
+ 'constraints' => [
+ new NotBlank(),
+ new File([
+ 'maxSize' => '2M',
+ 'mimeTypes' => [
+ 'application/pdf',
+ 'application/x-pdf',
+ ],
+ 'mimeTypesMessage' => 'Uniquement des fichiers PDF.',
+ ])
+ ]
+ ])
+ ->add('submit', SubmitType::class, [
+ 'label' => 'Envoyer',
+ ]);
+ }
+}
diff --git a/tests/behat/features/Admin/Members/GeneralMeeting/GeneralMeetingReports.feature b/tests/behat/features/Admin/Members/GeneralMeeting/GeneralMeetingReports.feature
new file mode 100644
index 000000000..dcabfad11
--- /dev/null
+++ b/tests/behat/features/Admin/Members/GeneralMeeting/GeneralMeetingReports.feature
@@ -0,0 +1,24 @@
+Feature: Administration - Partie Assemblée Générale CR
+
+ @reloadDbWithTestData
+ Scenario: Accède à la liste des CR
+ Given I am logged in as admin and on the Administration
+ And I follow "Assemblée générale"
+ Then the ".content h2" element should contain "Assemblée générale"
+ When I follow "Liste des comptes rendus"
+
+ # Liste
+ Then the ".content h2" element should contain "Assemblée générale - Comptes rendus"
+ And I should see "2014-02-15_CR AG AFUP 2013-2014"
+
+ # Ajout
+ And I attach the file "test_file1.pdf" to "report_file"
+ And I press "report[submit]"
+ Then the ".content .message" element should contain "Le compte rendu a correctement été ajouté."
+ And I should see "test_file1"
+
+ # Suppression
+ And I follow the button of tooltip "Supprimer le CR test_file1"
+ Then the ".content .message" element should contain "Le compte rendu a correctement été supprimé."
+
+