From 6a56c60fd1ee588dcd14a3ce64e5b7e018d83bb6 Mon Sep 17 00:00:00 2001 From: Arnaud Fornerot Date: Wed, 16 Feb 2022 09:07:04 +0100 Subject: [PATCH] svg --- .../src/Controller/QuestController.php | 49 ++++++++++++------- .../templates/Quest/quest.html.twig | 17 +++++-- .../templates/Survey/survey.html.twig | 16 +++++- 3 files changed, 59 insertions(+), 23 deletions(-) diff --git a/src/ninesurvey-1.0/src/Controller/QuestController.php b/src/ninesurvey-1.0/src/Controller/QuestController.php index 0698e79..aaf86da 100644 --- a/src/ninesurvey-1.0/src/Controller/QuestController.php +++ b/src/ninesurvey-1.0/src/Controller/QuestController.php @@ -8,12 +8,10 @@ use Symfony\Component\Form\FormError; use App\Form\CreateQuestFlow; use Ramsey\Uuid\Uuid; -use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\HttpKernel\KernelInterface; -use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse; -use Symfony\Component\Routing\Generator\UrlGenerator; -use Dompdf\Dompdf; -use Dompdf\Options; +use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\HttpFoundation\BinaryFileResponse; +use Symfony\Component\HttpFoundation\ResponseHeaderBag; use App\Entity\Quest; use App\Entity\Questoption; @@ -774,21 +772,10 @@ class QuestController extends AbstractController } } - if($type!="pdf") { - return $this->render('Quest/result.html.twig',[ - 'useheader' => true, - 'usesidebar' => false, - 'quest' => $quest, - 'questguests' => $questguests, - 'graphs' => $graphs, - 'access' => $access, - ]); - } - else { - + if($type=="pdf") { $rootdir = $this->appKernel->getProjectDir(); $filename="Enquete-".str_pad($id,5,"0",STR_PAD_LEFT).".pdf"; - $fileloc=$rootdir."/uploads/quest/".$filename; + $fileloc=$rootdir."/uploads/quest/$id/".$filename; $fs = new Filesystem(); $fs->remove(array($fileloc)); @@ -808,6 +795,32 @@ class QuestController extends AbstractController $this->knpSnappy->generateFromHtml($render,$fileloc); return $this->file($fileloc); } + elseif($type=="csv") { + $rootdir = $this->appKernel->getProjectDir()."/uploads/quest/$id"; + $filename="Enquete-".str_pad($id,5,"0",STR_PAD_LEFT).".csv"; + $fs = new Filesystem(); + $fs->mkdir($rootdir); + $csvh = fopen($rootdir."/".$filename, 'w'); + $d = ';'; // this is the default but i like to be explicit + $e = '"'; // this is the default but i like to be explicit + + $data=["id","Login","Nom","Prénom","Email","Téléphone"]; + fputcsv($csvh, $data, $d, $e); + fclose($csvh); + $response = new BinaryFileResponse($rootdir."/".$filename); + $response->setContentDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT); + return $response; + } + else { + return $this->render('Quest/result.html.twig',[ + 'useheader' => true, + 'usesidebar' => false, + 'quest' => $quest, + 'questguests' => $questguests, + 'graphs' => $graphs, + 'access' => $access, + ]); + } } public function resultbyguestkey($key,Request $request) diff --git a/src/ninesurvey-1.0/templates/Quest/quest.html.twig b/src/ninesurvey-1.0/templates/Quest/quest.html.twig index 413723c..0178843 100755 --- a/src/ninesurvey-1.0/templates/Quest/quest.html.twig +++ b/src/ninesurvey-1.0/templates/Quest/quest.html.twig @@ -13,6 +13,8 @@ } + .grid-full { width: 100% } + @media (max-width: 991px) { .grid-sizer, .grid-item { width: 100%; } .gutter-sizer { width: 0%; } @@ -136,13 +138,18 @@ {% endfor %} + +

Mes Participations

+ {% endblock %} {% block localjavascript %} $(document).ready(function() { + $(".notmy").detach().appendTo('.grid'); $(".notmy").hide(); + $(".notmytitle").hide(); $('.grid').masonry({ itemSelector: '.grid-item', columnWidth: '.grid-sizer', @@ -173,11 +180,15 @@ } $('#switchactive').change(function() { - if($(this).is(":checked")) + if($(this).is(":checked")) { $(".notmy").hide(); - else + $(".notmytitle").hide(); + } + else { $(".notmy").show(); - + $(".notmytitle").show(); + } + $('.grid').masonry({ itemSelector: '.grid-item', columnWidth: '.grid-sizer', diff --git a/src/ninesurvey-1.0/templates/Survey/survey.html.twig b/src/ninesurvey-1.0/templates/Survey/survey.html.twig index 92b2846..f3cc658 100755 --- a/src/ninesurvey-1.0/templates/Survey/survey.html.twig +++ b/src/ninesurvey-1.0/templates/Survey/survey.html.twig @@ -13,6 +13,8 @@ } + .grid-full { width: 100% } + @media (max-width: 991px) { .grid-sizer, .grid-item { width: 100%; } .gutter-sizer { width: 0%; } @@ -152,13 +154,19 @@ {% endfor %} + +

Mes Participations

+ {% endblock %} {% block localjavascript %} $(document).ready(function() { + $(".notmy").detach().appendTo('.grid'); $(".notmy").hide(); + $(".notmytitle").hide(); + $('.grid').masonry({ itemSelector: '.grid-item', columnWidth: '.grid-sizer', @@ -188,10 +196,14 @@ } $('#switchactive').change(function() { - if($(this).is(":checked")) + if($(this).is(":checked")) { $(".notmy").hide(); - else + $(".notmytitle").hide(); + } + else { $(".notmy").show(); + $(".notmytitle").show(); + } $('.grid').masonry({ itemSelector: '.grid-item',