templates/pdf/ficheProgressionSequence.html.twig line 1

Open in your IDE?
  1. <!DOCTYPE html>
  2. <html lang="fr">
  3. <head>
  4.     <meta charset="UTF-16">
  5.     <title>Fiche Séance</title>
  6.     <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,600,700" />
  7.     <style>
  8.         * {
  9.             font-family: 'Roboto';
  10.         }
  11.         table {
  12.             border-collapse: collapse;
  13.         }
  14.         th, td {
  15.             border: 1px solid black;
  16.         {%  if page %}
  17.             padding: 15px;
  18.         {%  endif %}
  19.         }
  20.         th {
  21.             background-color: #cccccc;
  22.         }
  23.         tr:first-child td:nth-child(1), .mytable tr:first-child td:nth-child(2) {
  24.             border:1px transparent;
  25.         }
  26.     </style>
  27. </head>
  28. <body >
  29. <div style="width: 100%; text-align: center">
  30.     <h1>Progression</h1>
  31. </div>
  32. <div id="bloc">
  33. <table id="myTable" style="width: 100%">
  34.     <tr>
  35.         <th>Jour</th>
  36.         <th>Séquence</th>
  37.         <th>Séance</th>
  38.         <th>Durée</th>
  39.     </tr>
  40.     {% set val = 0 %}
  41.     {% set sequence = 0 %}
  42.     {% set periodeCle = 0 %}
  43.     {% set date = "" %}
  44.     {% for progression_detail in progression.refProgressionDetails %}
  45.         {% if progression_detail.refPeriodeCle is null%}
  46.             {% if progression_detail.refSeance is not null%}
  47.                 {% if sequence != progression_detail.refSeance.refSequence.id %}
  48.                     {% set val = val+1 %}
  49.                     {% set sequence = progression_detail.refSeance.refSequence.id %}
  50.                 {% endif %}
  51.             <tr>
  52.                 <td>{{ progression_detail.date ? progression_detail.date|date('d/m/Y') : '' }}</td>
  53.                 <td data-toregroup="{{ val }}-{{ progression_detail.refSeance ? progression_detail.refSeance.refSequence : '' }}">{{ progression_detail.refSeance ? progression_detail.refSeance.refSequence : '' }}</td>
  54.                 <td>{{ progression_detail.refSeance ? progression_detail.refSeance : '' }}</td>
  55.                 <td>{{ progression_detail.refSeance ? progression_detail.refSeance.duree : '' }}</td>
  56.             </tr>
  57.             {% else %}
  58.                 {% set val = val+1 %}
  59.                 <tr>
  60.                     <td>{{ progression_detail.date ? progression_detail.date|date('d/m/Y') : '' }}</td>
  61.                     <td data-toregroup="{{ val }}-{{ progression_detail.refSeance ? progression_detail.refSeance.refSequence : '' }}">{{ progression_detail.refSeance ? progression_detail.refSeance.refSequence : '<i>Non défini</i>' }}</td>
  62.                     <td>{{ progression_detail.refSeance ? progression_detail.refSeance : '<i>Non défini</i>' }}</td>
  63.                     <td>{{ progression_detail.refSeance ? progression_detail.refSeance.duree : '' }}</td>
  64.                 </tr>
  65.             {% endif %}
  66.         {% else %}
  67.             {% if date != progression_detail.date|date('d/m/Y') %}
  68.                 {% set date = progression_detail.date|date('d/m/Y') %}
  69.                 {% if periodeCle != progression_detail.refPeriodeCle.id %}
  70.                     {% set val = val+1 %}
  71.                     {% set periodeCle = progression_detail.refPeriodeCle.id %}
  72.                 {% endif %}
  73.                 <tr style="background-color: {{ progression_detail.refPeriodeCle.refPeriodeType.couleur ~ '66' }}; color: {{ progression_detail.refPeriodeCle.refPeriodeType.couleur }}">
  74.                     <td>{{ progression_detail.date ? progression_detail.date|date('d/m/Y') : '' }}</td>
  75.                     <td colspan="3" data-toregroup="{{ val }}" >{{ progression_detail.refPeriodeCle }}</td>
  76.                 </tr>
  77.             {% endif %}
  78.         {% endif %}
  79.     {% endfor %}
  80. </table>
  81. </div>
  82. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
  83. <script>
  84.     $(function(){
  85.         //assumption: the column that you wish to rowspan is sorted.
  86.         //this is where you put in your settings
  87.         var indexOfColumnToRowSpan = 1;
  88.         var $table = $('#myTable');
  89.         //this is the code to do spanning, should work for any table
  90.         var rowSpanMap = {};
  91.         $table.find('tr').each(function(){
  92.             var valueOfTheSpannableCell = $($(this).children('td')[indexOfColumnToRowSpan]).data("toregroup");
  93.             $($(this).children('td')[indexOfColumnToRowSpan]).attr('data-original-value', valueOfTheSpannableCell);
  94.             rowSpanMap[valueOfTheSpannableCell] = true;
  95.         });
  96.         console.log(rowSpanMap)
  97.         for(var rowGroup in rowSpanMap){
  98.             console.log(rowGroup)
  99.             var $cellsToSpan = $('td[data-original-value="'+rowGroup+'"]');
  100.             console.log($cellsToSpan);
  101.             var numberOfRowsToSpan = $cellsToSpan.length;
  102.             $cellsToSpan.each(function(index){
  103.                 if(index==0){
  104.                     $(this).attr('rowspan', numberOfRowsToSpan);
  105.                 }else{
  106.                     $(this).hide();
  107.                 }
  108.             });
  109.         }
  110.     })();
  111. </script>
  112. </body>
  113. </html>