This commit is contained in:
Arnaud Fornerot 2022-02-16 09:07:04 +01:00
parent b40412eba6
commit 6a56c60fd1
3 changed files with 59 additions and 23 deletions

View File

@ -8,12 +8,10 @@ use Symfony\Component\Form\FormError;
use App\Form\CreateQuestFlow; use App\Form\CreateQuestFlow;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\HttpKernel\KernelInterface; use Symfony\Component\HttpKernel\KernelInterface;
use Knp\Bundle\SnappyBundle\Snappy\Response\PdfResponse; use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Routing\Generator\UrlGenerator; use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Dompdf\Dompdf; use Symfony\Component\HttpFoundation\ResponseHeaderBag;
use Dompdf\Options;
use App\Entity\Quest; use App\Entity\Quest;
use App\Entity\Questoption; use App\Entity\Questoption;
@ -774,21 +772,10 @@ class QuestController extends AbstractController
} }
} }
if($type!="pdf") { if($type=="pdf") {
return $this->render('Quest/result.html.twig',[
'useheader' => true,
'usesidebar' => false,
'quest' => $quest,
'questguests' => $questguests,
'graphs' => $graphs,
'access' => $access,
]);
}
else {
$rootdir = $this->appKernel->getProjectDir(); $rootdir = $this->appKernel->getProjectDir();
$filename="Enquete-".str_pad($id,5,"0",STR_PAD_LEFT).".pdf"; $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 = new Filesystem();
$fs->remove(array($fileloc)); $fs->remove(array($fileloc));
@ -808,6 +795,32 @@ class QuestController extends AbstractController
$this->knpSnappy->generateFromHtml($render,$fileloc); $this->knpSnappy->generateFromHtml($render,$fileloc);
return $this->file($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) public function resultbyguestkey($key,Request $request)

View File

@ -13,6 +13,8 @@
} }
.grid-full { width: 100% }
@media (max-width: 991px) { @media (max-width: 991px) {
.grid-sizer, .grid-item { width: 100%; } .grid-sizer, .grid-item { width: 100%; }
.gutter-sizer { width: 0%; } .gutter-sizer { width: 0%; }
@ -136,13 +138,18 @@
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
<div class="grid-item notmytitle grid-full mt-5"><h2>Mes Participations</h2></div>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
{% block localjavascript %} {% block localjavascript %}
$(document).ready(function() { $(document).ready(function() {
$(".notmy").detach().appendTo('.grid');
$(".notmy").hide(); $(".notmy").hide();
$(".notmytitle").hide();
$('.grid').masonry({ $('.grid').masonry({
itemSelector: '.grid-item', itemSelector: '.grid-item',
columnWidth: '.grid-sizer', columnWidth: '.grid-sizer',
@ -173,10 +180,14 @@
} }
$('#switchactive').change(function() { $('#switchactive').change(function() {
if($(this).is(":checked")) if($(this).is(":checked")) {
$(".notmy").hide(); $(".notmy").hide();
else $(".notmytitle").hide();
}
else {
$(".notmy").show(); $(".notmy").show();
$(".notmytitle").show();
}
$('.grid').masonry({ $('.grid').masonry({
itemSelector: '.grid-item', itemSelector: '.grid-item',

View File

@ -13,6 +13,8 @@
} }
.grid-full { width: 100% }
@media (max-width: 991px) { @media (max-width: 991px) {
.grid-sizer, .grid-item { width: 100%; } .grid-sizer, .grid-item { width: 100%; }
.gutter-sizer { width: 0%; } .gutter-sizer { width: 0%; }
@ -152,13 +154,19 @@
</div> </div>
</div> </div>
{% endfor %} {% endfor %}
<div class="grid-item notmytitle grid-full mt-5"><h2>Mes Participations</h2></div>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
{% block localjavascript %} {% block localjavascript %}
$(document).ready(function() { $(document).ready(function() {
$(".notmy").detach().appendTo('.grid');
$(".notmy").hide(); $(".notmy").hide();
$(".notmytitle").hide();
$('.grid').masonry({ $('.grid').masonry({
itemSelector: '.grid-item', itemSelector: '.grid-item',
columnWidth: '.grid-sizer', columnWidth: '.grid-sizer',
@ -188,10 +196,14 @@
} }
$('#switchactive').change(function() { $('#switchactive').change(function() {
if($(this).is(":checked")) if($(this).is(":checked")) {
$(".notmy").hide(); $(".notmy").hide();
else $(".notmytitle").hide();
}
else {
$(".notmy").show(); $(".notmy").show();
$(".notmytitle").show();
}
$('.grid').masonry({ $('.grid').masonry({
itemSelector: '.grid-item', itemSelector: '.grid-item',