Commit a43d511a authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

Amélioration affichage

parent e517a77f
Loading
Loading
Loading
Loading
Loading
+29 −5
Original line number Diff line number Diff line
@@ -335,14 +335,32 @@ $nbElements = count($elements);
                </thead>
                <tbody>
                <?php if (isset($comments[$question->getId()])) : ?>
                    <?php foreach ($comments[$question->getId()] as [$note, $commentaire]) : ?>
                        <tr>
                    <?php
                        $commentaires = $comments[$question->getId()];
                        usort($commentaires, function ($a, $b) { return $a[0] <=> $b[0]; });
                        $sortedCommentaires = [];
                        foreach ($commentaires as $commentaire) {
                            $sortedCommentaires[$commentaire[0]][] = $commentaire[1];
                        }

                    ?>
                    <?php foreach ($sortedCommentaires as $note => $liste) : ?>
                                                    <?php if ($question->hasNote()) : ?>
                                <th><?php echo $note; ?></th>

                        <tr>
                            <th rowspan="<?php echo count($liste)+1; ?>" class="toggler" id="<?php echo $note; ?>">
                                <?php echo $reponses[$note]??"Sans avis"; ?>
                            </th>
                            <td> <?php echo count($liste); ?> réponse·s</td>
                        </tr>
                                                    <?php endif; ?>
                        <?php foreach ($liste as $commentaire) : ?>

                            <tr class="comments_<?php echo $note; ?>">
                                <td><?php echo $commentaire; ?></td>
                            </tr>
                        <?php endforeach; ?>
                    <?php endforeach; ?>
                <?php endif; ?>
                </tbody>
            </table>
@@ -459,4 +477,10 @@ $nbElements = count($elements);
        let tableau = brut;
        downloadCSVFromJson('enquete_brut_' + $(this).attr('id') + '_' + Date.now().toString() + '.csv', header, tableau);
    });

    $('th.toggler').on('click', function () {
        let id = $(this).attr("id");
        console.log(id);
        $('tr.comments_' + id + ' td').toggle();
    });
</script>
 No newline at end of file