templates/reutilisation.html.twig line 1

Open in your IDE?
  1. {% extends 'baseQuveo.html.twig' %}
  2. {# {% block stylesheets %}
  3. <meta charset="utf-8">
  4. {% endblock %} #}
  5. {% block body %}
  6.   <script>
  7.       
  8.       
  9.     // Code JavaScript pour afficher/masquer le texte
  10.     function toggleContent(button, content) {
  11.       button.addEventListener("click", function() {
  12.         if (content.style.display === "none" || content.style.display === "") {
  13.           content.style.display = "block";
  14.           button.textContent = "▲"; // Flèche vers le haut
  15.         } else {
  16.           content.style.display = "none";
  17.           button.textContent = "▼"; // Flèche vers le bas
  18.         }
  19.       });
  20.     }
  21.   </script>
  22. {#<div style="margin-left: 20px; margin-right: 20px;">#}
  23. <div class="w-75 mx-auto">
  24.     
  25.     <br>
  26.     <p class="h4">Calculez le taux de réutilisation de vos eaux pluviales :</p>    
  27.     <br>
  28.     {{ form_start(form) }}
  29.     {{ form_errors(form) }}
  30.             {{ form_label(form.nomDuProjet, 'Nom du projet') }}
  31.             {{ form_widget(form.nomDuProjet, {'attr': {'value': fichePluvio.nomDuProjet}}) }}
  32.     <div class="form-row">
  33.         <div class="form-group col-md-4">
  34.             {{ form_label(form.anneesCalculees, 'Années à calculer') }}
  35.             {{ form_widget(form.anneesCalculees, {'attr': {'value': fichePluvio.anneesCalculees}}) }}</div>
  36.         <div class="form-group col-md-3">
  37.             {{ form_label(form.stationAPI, 'Station météo') }}
  38.             {{ form_widget(form.stationAPI, {'attr': {'value': fichePluvio.stationAPI}}) }}</div>
  39.     </div>
  40.     <div class="form-row">
  41.         <div class="form-group col-md-4">
  42.             {{ form_label(form.climat, 'Climat') }}
  43.             {{ form_widget(form.climat, {'attr': {'value': fichePluvio.climat}}) }}</div>
  44.         <div class="form-group col-md-3">
  45.             {{ form_label(form.stationmeteo, 'Station météo') }}
  46.             {{ form_widget(form.stationmeteo, {'attr': {'value': fichePluvio.stationMeteo}}) }}</div>
  47.     </div>
  48.     <div class="form-row">
  49.                 <div class="form-group col-md-4">            
  50.             {{ form_label(form.nomSurface, 'Nom de la surface 1') }}
  51.             {{ form_widget(form.nomSurface, {'attr': {'value': fichePluvio.nomSurface}}) }}</div>
  52.         <div class="form-group col-md-3">            
  53.             {{ form_label(form.surfaceRecuperee, 'Surface de toiture récupérée en m²') }}
  54.             {{ form_widget(form.surfaceRecuperee, {'attr': {'value': fichePluvio.surfaceRecuperee}}) }}</div>
  55.         <div class="form-group col-md-3">
  56.             {{ form_label(form.rendementToiture, 'Type de toiture') }}
  57.             {{ form_widget(form.rendementToiture, {'attr': {'value': fichePluvio.rendementToiture}}) }}</div>
  58.                     <div class="form-group col-md-1">
  59.                     <img src="{{ asset('img/information.png') }}" height="18" title="Kt est le coefficient de rendement de la toiture (La gestion durable de l'eau - CSTB 2009)">
  60.                     </a></div>
  61.     </div>
  62.             
  63.         <div>
  64.         <button type="button" id="toggleButton1" style="font-size: 12px;">▼</button>
  65.         <label for="toggleButton1">Ajouter d'autres toitures:</label>
  66.         </div>
  67.     <div id="texte1" style="display: none;">
  68.     <div class="form-row">
  69.                         <div class="form-group col-md-4">            
  70.             {{ form_label(form.nomSurface2, 'Nom de la surface 2') }}
  71.             {{ form_widget(form.nomSurface2, {'attr': {'value': fichePluvio.nomSurface2}}) }}</div>
  72.         <div class="form-group col-md-3">            
  73.             {{ form_label(form.surfaceRecuperee2, 'Surface n°2 de toiture récupérée') }}
  74.             {{ form_widget(form.surfaceRecuperee2, {'attr': {'value': fichePluvio.surfaceRecuperee2}}) }}</div>
  75.         <div class="form-group col-md-3">
  76.             {{ form_label(form.rendementToiture2, 'Type de toiture n°2') }}
  77.             {{ form_widget(form.rendementToiture2, {'attr': {'value': fichePluvio.rendementToiture2}}) }}</div>
  78.     </div>
  79.     <div class="form-row">
  80.                         <div class="form-group col-md-4">            
  81.             {{ form_label(form.nomSurface3, 'Nom de la surface 3') }}
  82.             {{ form_widget(form.nomSurface3, {'attr': {'value': fichePluvio.nomSurface3}}) }}</div>
  83.         <div class="form-group col-md-3">            
  84.             {{ form_label(form.surfaceRecuperee3, 'Surface n°3 de toiture récupérée') }}
  85.             {{ form_widget(form.surfaceRecuperee3, {'attr': {'value': fichePluvio.surfaceRecuperee3}}) }}</div>
  86.         <div class="form-group col-md-3">
  87.             {{ form_label(form.rendementToiture3, 'Type de toiture n°3') }}
  88.             {{ form_widget(form.rendementToiture3, {'attr': {'value': fichePluvio.rendementToiture3}}) }}</div>
  89.     </div>
  90.     </div>
  91.     <div>
  92.       <button type="button" id="toggleButton2" style="font-size: 12px;">▼</button>
  93.       <label for="toggleButton2">Usage pour les WC :</label>
  94.     </div>
  95.     <div id="texte2" style="display: none;">   
  96.         <div class="form-row">
  97.             <div class="form-group col-md-3">
  98.                 {{ form_label(form.nbreUtilisateur, 'Nombre d\'utilisateur moyen journalier') }}
  99.                 {{ form_widget(form.nbreUtilisateur, {'attr': {'value': fichePluvio.nbreUtilisateur}}) }}</div>
  100.             <div class="form-group col-md-3">
  101.                  {{ form_label(form.volumeParUtilisation, 'Volume par jour par utilisateur (L/jr)') }}
  102.                 {{ form_widget(form.volumeParUtilisation, {'attr': {'value': fichePluvio.volumeParUtilisation}}) }}</div>
  103.             <div class="form-group col-md-2">
  104.                 {{ form_label(form.scenarioUtilisation, 'Scénario d\'utilisation') }}
  105.                 {{ form_widget(form.scenarioUtilisation, {'attr': {'value': fichePluvio.scenarioUtilisation}}) }}</div>
  106.             <div class="form-group col-md-3">
  107.                 {{ form_label(form.tauxRaccordement, 'Taux de WC raccordés en %') }}
  108.                 {{ form_widget(form.tauxRaccordement, {'attr': {'value': fichePluvio.tauxRaccordement}}) }}</div>
  109.         </div>
  110.     </div>
  111.         
  112.     <div>
  113.       <button type="button" id="toggleButton3" style="font-size: 12px;">▼</button>
  114.       <label for="toggleButton3">Usage pour l'arrosage :</label>
  115.     </div>
  116.     <div id="texte3" style="display: none;">
  117.         <div class="form-row">
  118.             <div class="form-group col-md-3">
  119.                 {{ form_label(form.ru, 'Type de sol') }}
  120.                 {{ form_widget(form.ru, {'attr': {'value': fichePluvio.ru}}) }}</div>
  121.             <div class="form-group col-md-3">
  122.                 {{ form_label(form.typePlante, 'Type de plantes') }}
  123.                 {{ form_widget(form.typePlante) }}
  124.                 {#            {{ form_widget(form.typePlante, {'attr': {'value': fichePluvio.typePlante}}) }}
  125.                 #}        </div>
  126.             <div class="form-group col-md-3">
  127.                 {{ form_label(form.profondeurTerre, 'Profondeur de la terre') }}
  128.                 {{ form_widget(form.profondeurTerre, {'attr': {'value': fichePluvio.profondeurTerre}}) }}</div>
  129.             <div class="form-group col-md-3">
  130.                 {{ form_label(form.sArrosage, 'Surface arrosée en m²') }}
  131.                 {{ form_widget(form.sArrosage, {'attr': {'value': fichePluvio.sArrosage}}) }}
  132.             </div>
  133.         </div>
  134.     </div>
  135.     
  136.     <div>
  137.       <button type="button" id="toggleButton4" style="font-size: 12px;">▼</button>
  138.       <label for="toggleButton4">Autres besoins :</label>
  139.     </div>
  140.     <div id="texte4" style="display: none;">
  141.     <div class="form-row">
  142.         <div class="form-group col-md-3">
  143.             {{ form_label(form.besoinEau, 'Autre besoin en eau en litres par jour :') }}
  144.             {{ form_widget(form.besoinEau, {'attr': {'value': fichePluvio.besoinEau}}) }}</div> 
  145.         <div class="form-group col-md-1">
  146.             <img src="{{ asset('img/information.png') }}" height="18" title="Lavage du sol, remplissage de camionnettes autolaveuses... Si le besoin varie suivant les jours, séparez les données par un point-virgule. Les données seront répétées. Exemple : une suite de 7 chiffres '4;0;9;0;0;0;0' pour une suite hebdomadaire">
  147.             </a>
  148.         </div>
  149.     </div>
  150.     </div>        
  151.             
  152.             <div>
  153.       <button type="button" id="toggleButton5" style="font-size: 12px;">▼</button>
  154.       <label for="toggleButton5">Analyse économique :</label>
  155.             </div>
  156.             <div id="texte5" style="display: none;">
  157.                 <div class="form-row" style="background:#f8f9fa">
  158.                 </div>
  159.                 <div class="form-row" style="background:#f8f9fa">
  160.                     <div class="form-group col-md-3">
  161.                         {{ form_label(form.coutEau, 'Coût de l\'eau épargnée en €/m3') }}
  162.                         {{ form_widget(form.coutEau, {'attr': {'value': fichePluvio.coutEau}}) }}
  163.                     </div>
  164.                     <div class="form-group col-md-6">
  165.                         {{ form_label(form.coutPompe, 'Forfait pour le coût de la pompe et du double réseau en €') }}
  166.                         {{ form_widget(form.coutPompe, {'attr': {'value': fichePluvio.coutPompe}}) }}
  167.                     </div>
  168.                 </div>
  169.                 <div class="form-row" style="background:#f8f9fa">
  170.                     <div class="form-group col-md-2">
  171.                         Volumes et coûts de cuve à interpoler :
  172.                     </div>
  173.                     <div class="form-group col-md-2">
  174.                         {{ form_label(form.choixVolume, 'Volume n°1 en litres') }}
  175.                         {{ form_widget(form.choixVolume, {'attr': {'value': fichePluvio.choixVolume}}) }}
  176.                     </div>
  177.                     <div class="form-group col-md-2">
  178.                         {{ form_label(form.coutVolume, 'Coût du volume n°1') }}
  179.                         {{ form_widget(form.coutVolume, {'attr': {'value': fichePluvio.coutVolume}}) }}
  180.                     </div>
  181.                     <div class="form-group col-md-2">
  182.                         {{ form_label(form.choixVolume2, 'Volume n°2 en litres') }}
  183.                         {{ form_widget(form.choixVolume2, {'attr': {'value': fichePluvio.choixVolume2}}) }}
  184.                     </div>
  185.                     <div class="form-group col-md-2">
  186.                         {{ form_label(form.coutVolume2, 'Coût du volume n°2') }}
  187.                         {{ form_widget(form.coutVolume2, {'attr': {'value': fichePluvio.coutVolume2}}) }}
  188.                     </div>
  189.                 </div>
  190.             </div>
  191.           <div class="form-group col-md-4">
  192.             {{ form_label(form.certivea, 'L\'operation est-elle certifiée HQE par Certivéa \?') }}
  193.             {{ form_widget(form.certivea, {'attr': {'value': fichePluvio.certivea}}) }}
  194.         </div>          
  195. <script>
  196. if ({{ fichePluvio.nbreUtilisateur }}0 > 0) {
  197.     document.getElementById("texte2").style.display = "block";
  198.     document.getElementById("toggleButton2").textContent = "▲";
  199. } else {
  200.     document.getElementById("texte2").style.display = "none";
  201.     document.getElementById("toggleButton2").textContent = "▼";
  202. }
  203. if ({{ fichePluvio.surfaceRecuperee2 }}0 > 0) {
  204.     document.getElementById("texte1").style.display = "block";
  205.     document.getElementById("toggleButton1").textContent = "▲";
  206. } else {
  207.     document.getElementById("texte1").style.display = "none";
  208.     document.getElementById("toggleButton1").textContent = "▼";
  209. }
  210. if ({{ fichePluvio.sArrosage }}0 > 0) {
  211.     document.getElementById("texte3").style.display = "block";
  212.     document.getElementById("toggleButton3").textContent = "▲";
  213. } else {
  214.     document.getElementById("texte3").style.display = "none";
  215.     document.getElementById("toggleButton3").textContent = "▼";
  216. }
  217. let besoinEau = parseFloat('{{ fichePluvio.besoinEau|split(";")|first|default(0) }}');
  218. if (besoinEau > 0) {
  219.     document.getElementById("texte4").style.display = "block";
  220.     document.getElementById("toggleButton4").textContent = "▲";
  221. } else {
  222.     document.getElementById("texte4").style.display = "none";
  223.     document.getElementById("toggleButton4").textContent = "▼";
  224. }
  225. // Code JavaScript for afficher le texte lorsque la case est cochée
  226. toggleContent(document.getElementById("toggleButton1"), document.getElementById("texte1"));
  227. toggleContent(document.getElementById("toggleButton2"), document.getElementById("texte2"));
  228. toggleContent(document.getElementById("toggleButton3"), document.getElementById("texte3"));
  229. toggleContent(document.getElementById("toggleButton4"), document.getElementById("texte4"));
  230. toggleContent(document.getElementById("toggleButton5"), document.getElementById("texte5"));
  231. </script>
  232.            {% if  graphParametrique %}     
  233. <BR>
  234. <BR>
  235. <p class="h4">Résultats de l'étude :</p>
  236.             
  237. <BR>
  238. <BR>           
  239.             
  240.         <div id="chartParamatrique" style="height: 370px; width: 100%;"></div>
  241.     {% endif %}
  242.      {% if  graphParametrique %}
  243.     <br><br> 
  244.     <table class='table table-striped table-hover table-sm text-center'>
  245.         <thead>
  246.         <tr>
  247.         <th>Volume de la cuve en Litres</th>
  248.         <th >Taux d'autonomie en %</th>
  249.         <th >Quantitée réutilisée moyenne en m3/an</th>
  250.         <th >Complément annuel moyen m3/an</th>
  251.         <th >Trop plein moyen en m3/an</th>
  252.         <th >Gain financier moyen annuel en €/an</th>
  253.         <th >Coût de la cuve + réseau estimée en €HT</th>
  254.         <th >Temps de retour brut en années</th>
  255.         </tr>
  256.     </thead>  
  257.     <tbody>
  258.         {% for Volume in tableauParametrique %}
  259.             <tr>
  260.                 {% for data in Volume %}
  261.                     <td>
  262.                         {{ data }}
  263.                     </td>
  264.                 {% endfor %}
  265.             </tr>
  266.         {% endfor %}
  267.     </tbody>
  268. </table>
  269.             <br><br> 
  270.         <table class='table table-striped table-hover table-sm text-center'>
  271.             <thead>
  272.             <tr>
  273.             <th>Pluviométrie moyenne en mm/an</th>
  274.             <th >Besoin total en eau en m3/an</th>
  275.             <th >Arrosage en mm/an</th>
  276.             </tr>
  277.         </thead>  
  278.         <tbody>
  279.             <tr>
  280.                 <td>
  281.                     {{ tableauSynthese.pluviometrieMoyenne }}
  282.                 </td>
  283.                 <td>
  284.                     {{ tableauSynthese.besoinAnnuel }}
  285.                 </td>
  286.                 <td>
  287.                     {{ tableauSynthese.besoinArrosage }}
  288.                 </td>
  289.             </tr>
  290.         </tbody>
  291.     </table>
  292.                 
  293.     <BR>
  294.     <BR>  
  295.     <p class="h5">Obtenez les graphiques jour par jour en choisisssant le volume de la cuve. 
  296.         Un optimum de volume peut être au fléchissement de la courbe du taux de couverture.</p>
  297.     <BR>
  298.     <div class="form-row mt-4" {% if not show_complement %}style="display:none"{% endif %}>
  299.         <div class="form-group col-md-4" >
  300.             {{ form_row(form.volumeCuve, {'label': 'Volume de la cuve choisi en Litres (optionnel) :'}) }}</div>
  301.         <div class="form-group col-md-1 align-self-center d-flex justify-content-center"> OU </div>
  302.         <div class="form-group col-md-4">{{ form_row(form.tauxObjectif, {'label': 'Taux couverture souhaité en %'}) }}</div>
  303.     </div>
  304.     <div class="form-row mt-4">
  305.         <div class="form-group col-md-2">
  306.         {%if show_complement %}
  307.             {{ form_row(form.analyser, {'label': 'Compléter et/ou actualiser l\'analyse'}) }}
  308. {#            <a class="btn btn-primary" href="{{ path('CopieCalcul') }}" role="button">Faire une copie du calcul</a>
  309.             <a class="btn btn-primary" href="{{ path('NouveauCalcul') }}" role="button">Nouveau calcul</a>#}
  310.             {% else %}
  311.             {{ form_row(form.analyser ) }}
  312.             {% endif %}
  313.         </div>
  314.     </div>
  315.     {% else %}
  316.         <div class="form-row mt-4" {% if not show_complement %}style="display:none"{% endif %}>
  317.             <div class="form-group col-md-4">
  318.                 {{ form_row(form.volumeCuve, {'label': 'Volume de la cuve choisi en Litres (optionnel) :'}) }}</div>
  319.             <div class="form-group col-md-1 align-self-center d-flex justify-content-center"> OU</div>
  320.             <div class="form-group col-md-4">{{ form_row(form.tauxObjectif, {'label': 'Taux couverture souhaité en %'}) }}</div>
  321.         </div>
  322.         <div class="form-row mt-4">
  323.             <div class="form-group col-md-2">
  324.                 {% if show_complement %}oo
  325.                     {{ form_row(form.analyser, {'label': 'Compléter et/ou actualiser l\'analyse'}) }}
  326.                 {% else %}
  327.                     {{ form_row(form.analyser ) }}
  328.                 {% endif %}
  329.             </div>
  330.         </div>
  331.     {% endif %}
  332.     
  333. {{ form_rest(form) }}
  334. {{ form_end(form) }}
  335.     <br><br> 
  336.     <script type="text/javascript" src="https://canvasjs.com/assets/script/canvasjs.min.js"></script>   
  337.     {% if  volumeCuveUser %}
  338.         
  339.         Détails pour le volume choisi : {{ volumeCuveUser }} Litres:
  340.         <BR>
  341.         <BR>
  342.         <div id="chartPie" style="height: 370px; width: 100%;"></div>
  343.         <div id="chartPluviometrie" style="height: 100px; width: 100%;"></div><br><br>
  344.         <div id="chartContainer" style="height: 370px; width: 100%;"></div><br><br>
  345.         <div id="chartBarres" style="height: 370px; width: 100%;"></div><br><br>
  346.         
  347.     {% endif %}
  348.    
  349. {% if allowPDF %}
  350. <a class="btn btn-success btnPDF" >Télécharger le bilan en PDF</a>
  351. {% endif %}
  352. <br><br>
  353. {#
  354. {% if  graphParametrique %} Tableau de vérification
  355. <br><br> 
  356. <table class='table table-striped table-hover table-sm'>
  357.     <thead>
  358.     <th>jour</th>
  359.     <th >pluieDuJour</th>
  360.     <th >RFUJournalier</th>
  361.     <th >ETP</th>
  362.     <th >ConsoPlanteJournalier</th>
  363.     <th >besoinArrosageJournalier</th>
  364.     <th >besoinEauJournalier</th>
  365.     <th >volumeEauToiture</th>
  366.     <th >volumeEau</th>
  367.     <th >bilanEau</th>
  368.     <th >manqueEau)</th>
  369. </thead>  
  370. <tbody>
  371.     {% for jour in tableau %}
  372.         <tr>
  373.             {% for data in jour %}
  374.                 <td>
  375.                     {{ data }}
  376.                 </td>
  377.             {% endfor %}
  378.         </tr>
  379.     {% endfor %}
  380. </tbody>
  381. </table>
  382. {% endif %}#}
  383. <script>
  384.     //let myForm = document.getElementById('form');
  385.         document.querySelectorAll('form select').forEach(elem => {
  386.         elem.addEventListener('submit', function(e){ e.preventDefault(); });
  387.     });
  388.     function showFile(blob){
  389.         // It is necessary to create a new blob object with mime-type explicitly set
  390.         // otherwise only Chrome works like it should
  391.         var newBlob = new Blob([blob], {type: "application/pdf"})
  392.         // IE doesn't allow using a blob object directly as link href
  393.         // instead it is necessary to use msSaveOrOpenBlob
  394.         if (window.navigator && window.navigator.msSaveOrOpenBlob) {
  395.             window.navigator.msSaveOrOpenBlob(newBlob);
  396.             return;
  397.         }
  398.         // For other browsers:
  399.         // Create a link pointing to the ObjectURL containing the blob.
  400.         const data = window.URL.createObjectURL(newBlob);
  401.         var link = document.createElement('a');
  402.         link.href = data;
  403.         link.download="bilan.pdf";
  404.         link.click();
  405.         setTimeout(function(){
  406.             // For Firefox it is necessary to delay revoking the ObjectURL
  407.             window.URL.revokeObjectURL(data);
  408.         }, 100);
  409.     }
  410.     const pdfLink="{{ path('RetutilisationBilanPdf',{'idFiche' : idPluvio}) }}";
  411.     const btnPDF = document.querySelector('.btnPDF');
  412.     if (btnPDF) {
  413. // On click convert charts to png and download pdf
  414.         btnPDF.addEventListener('click', () => {
  415.             // create new FormData object
  416.             const formData = new FormData();
  417.             // append form data to formData object
  418.         formData.append('idFiche', {{ idPluvio }});
  419.             // Convert charts to png
  420.         const charts = document.querySelectorAll('.canvasjs-chart-container');
  421.         var index=0;
  422.         charts.forEach(container => {
  423.             chart = container.querySelector('canvas');
  424.             console.log(chart);
  425.                 const img = chart.toDataURL("image/png");
  426.                 // add Img from chart to formData
  427.             formData.append('img['+(index++)+']', img);
  428.             });
  429.             // Send multipart formData to server
  430.             fetch(pdfLink, {
  431.                 method: 'POST',
  432.             body: formData
  433.         }).then(r => r.blob())
  434.             .then(showFile)
  435.         });
  436.     }
  437.     function generatePDF() {
  438.         var doc = new jsPDF();
  439.         doc.fromHTML(document.getElementById('content'), 15, 15, {
  440.             'width': 170
  441.         });
  442.         doc.save('sample-file.pdf');
  443.     }
  444. </script>
  445. <script>
  446.     var renderedImages = [];
  447.     window.onload = function () {
  448.         {% if graphParametrique %}
  449.     var chart = new CanvasJS.Chart("chartParamatrique", {
  450.     animationEnabled: true,
  451.             zoomEnabled: true,
  452.             theme: "light2",
  453.             title: {
  454.             text: "Etude paramétrique de la taille de la cuve"
  455.             },
  456.             axisX: {
  457.             title: "Nombre de litres",
  458.                     titleFontColor: "#4F81BC",
  459.                     includeZero: true,
  460.                     valueFormatString: "# ###L",
  461.             },
  462.             axisY: {
  463.             title: "Taux de couverture des besoins",
  464.                     titleFontColor: "#4F81BC",
  465.                     includeZero: true,
  466.                     suffix: "%"
  467.             },
  468.             axisY2: {
  469.             title: "Temps de retour",
  470.                     titleFontColor: "#4F81BC",
  471.                     includeZero: true,
  472.                     suffix: " ans"
  473.             },
  474.             toolTip: {
  475.             shared: true
  476.             },
  477.             data: [{
  478.             indexLabelFontColor: "darkSlateGray",
  479.                     name: "Taux de couverture",
  480.                     type: "line",
  481.                     markerSize: 0,
  482.                     showInLegend: true,
  483.                     xValueFormatString: "Volume cuve : # ###L",
  484.                     yValueFormatString: "# '%'",
  485.                     dataPoints: [
  486.     {{ graphParametrique }}
  487.                         ]
  488.                 },
  489.                 {
  490.                 indexLabelFontColor: "red",
  491.                         name: "Selection utilisateur",
  492.                         type: "line",
  493.                         markerSize: 12,
  494.                         showInLegend: true,
  495.                         yValueFormatString: "Couverture à #'%'",
  496.                         dataPoints: [
  497.     {{ graphParametriqueUserJson }}
  498.                         ]},
  499.                 {
  500.                 type: "line",
  501.                         name: "Temps de retour",
  502.                         axisYType: "secondary",
  503.                         markerSize: 0,
  504.                         showInLegend: true,
  505.                         yValueFormatString: "0.0 ans",
  506.                         dataPoints:[
  507.     {{ graphTempsDeRetour }}
  508.                         ]
  509.                 }
  510.                 ]
  511.         });
  512.         chart.render();
  513.         renderedImages.push(chart.exportChart({format: "png",toDataURL: true}));
  514.         {% endif %}
  515.         {% if graphJourParJour %}
  516.         {% endif %}
  517.         {% if  volumeCuveUser %}
  518.         var chart1 = new CanvasJS.Chart("chartContainer", {
  519.         animationEnabled: true,
  520.                 zoomEnabled: true,
  521.                 theme: "light2",
  522.                 title: {
  523.                 text: "Niveau de la cuve de la première année"
  524.                 },
  525.                 axisX: {
  526.                 title: "Jour dans l'année",
  527.                         titleFontColor: "#4F81BC",
  528.                         includeZero: true,
  529.                         suffix: ""
  530.                 },
  531.                 axisY: {
  532.                 title: "Nombre de litres",
  533.                         titleFontColor: "#4F81BC",
  534.                         includeZero: true,
  535.                         scaleBreaks: {
  536.                         autoCalculate: true
  537.                         },
  538.                         suffix: " L",
  539.                         maximum:{{graphJourParJour.maximum}}
  540.                 },
  541.                 data: [
  542.                 {
  543.                 indexLabelFontColor: "red",
  544.                         name: "Trop plein de la cuve",
  545.                         type: "area",
  546.                         showInLegend: true,
  547.                         color: "#DF7970",
  548.                         yValueFormatString: "# ##0 L",
  549.                         xValueFormatString: "J#",
  550.                         dataPoints: [
  551.     {{ graphJourParJour.tropPlein }}
  552.                         ]
  553.                 },
  554.                 {
  555.                 indexLabelFontColor: "green",
  556.                         name: "Complément eau de ville",
  557.                         type: "area",
  558.                         showInLegend: true,
  559.                         color:"#51CDA0",
  560.                         yValueFormatString: "# ##0 L",
  561.                         xValueFormatString: "J#",
  562.                         dataPoints: [
  563.     {{ graphJourParJour.manqueEau }}
  564.                         ]
  565.                 },
  566.                 {indexLabelFontColor: "darkSlateGray",
  567.                         name: "Volume d'eau dans la cuve",
  568.                         type: "area",
  569.                         showInLegend: true,
  570.                         color: "#6D78AD",
  571.                         yValueFormatString: "# ##0 L",
  572.                         xValueFormatString: "J#",
  573.                         dataPoints: [
  574.     {{ graphJourParJour.volumeEau }}
  575.                         ]
  576.                 }
  577.                 ]
  578.         });
  579.         chart1.render();
  580.         renderedImages.push(chart1.exportChart({format: "png",toDataURL: true}));
  581.         {% endif %}
  582.         {% if  volumeCuveUser %}
  583.         var chart3 = new CanvasJS.Chart("chartBarres", {
  584.         animationEnabled: true,
  585.                 zoomEnabled: true,
  586.                 theme: "light2",
  587.                 title: {
  588.                 text: "Répartition des besoins jour par jour sur la première année"
  589.                 },
  590.                 axisX: {
  591.                 title: "Jour dans l'année",
  592.                         titleFontColor: "#4F81BC",
  593.                         includeZero: true,
  594.                         suffix: ""
  595.                 },
  596.                 axisY: {
  597.                 title: "Nombre de litres",
  598.                         titleFontColor: "#4F81BC",
  599.                         includeZero: true,
  600.                         suffix: " L"
  601.                 },
  602.                 data: [{
  603.                 indexLabelFontColor: "green",
  604.                         name: "Eau de pluie réutilisée",
  605.                         type: "stackedColumn",
  606.                         yValueFormatString: "# ##0 L",
  607.                         xValueFormatString: "J#",
  608.                         showInLegend: true,
  609.                         dataPoints: [
  610.     {{ graphJourParJour.apportCuve }}
  611.                         ]
  612.                 },
  613.                 {
  614.                 indexLabelFontColor: "darkSlateGray",
  615.                         name: "Complément eau de ville",
  616.                         showInLegend: true,
  617.                         type: "stackedColumn",
  618.                         yValueFormatString: "# ##0 L",
  619.                         xValueFormatString: "J#",
  620.                         dataPoints: [
  621.     {{ graphJourParJour.manqueEauPositif }}
  622.                         ]
  623.                 }
  624.                 ]
  625.         });
  626.         chart3.render();
  627.         renderedImages.push(chart3.exportChart({format: "png",toDataURL: true}));
  628.         {% endif %}
  629.         {% if  volumeCuveUser %}
  630.         var chart2 = new CanvasJS.Chart("chartPluviometrie", {
  631.         animationEnabled: true,
  632.                 theme: "light2",
  633.                 title: {
  634.                 text: "Pluviometrie"
  635.                 },
  636.                 axisX: {
  637.     {#        minimum: new Date(2015, 01, 25),
  638.                     maximum: new Date(2017, 02, 15),
  639.                     valueFormatString: "MMM YY"#}
  640.                                 },
  641.                                 axisY: {
  642.                                 title: "mm par jour",
  643.                                         titleFontColor: "#4F81BC",
  644.                                         includeZero: true,
  645.                                         suffix: ""
  646.                                 },
  647.                                 data: [{
  648.                                 indexLabelFontColor: "darkSlateGray",
  649.                                         name: "views",
  650.                                         type: "area",
  651.                                         yValueFormatString: "0.0",
  652.                                         dataPoints: [
  653.     {{ graphJourParJour.pluviometrie }}
  654.                         ]
  655.                 }]
  656.         });
  657.         chart2.render();
  658.         renderedImages.push(chart2.exportChart({format: "png",toDataURL: true}));
  659.         {% endif %}
  660.         {% if  volumeCuveUser %}
  661.         var chartpie = new CanvasJS.Chart("chartPie", {
  662.         animationEnabled: true,
  663.                 theme: "light2",
  664.                 title: {
  665.                 text: "Répartition des besoins"
  666.                 },
  667.                 data: [{
  668.                 type: "pie",
  669.                         startAngle: 240,
  670.                         yValueFormatString: "0.0%",
  671.                         indexLabel: "{label} {y}",
  672.                         dataPoints: [
  673.                         {y:{{graphTarte.tauxArrosage}}, label: "Arrosage ({{graphTarte.Arrosage}} m3/an) :"},
  674.                         {y:{{graphTarte.tauxWc}}, label: "WC ({{graphTarte.Wc}} m3/an) :"},
  675.                         {y:{{graphTarte.tauxAutres}}, label: "Autres ({{graphTarte.Autres}} m3/an) :"},
  676.                         ]
  677.                 }]
  678.         });
  679.         chartpie.render();
  680.         renderedImages.push(chartpie.exportChart({format: "png",toDataURL: true}));
  681.         {% endif %}
  682.         }
  683. </script>
  684. <script>
  685. document.addEventListener("DOMContentLoaded", function() {
  686.     let anneesInput = document.querySelector("#{{ form.anneesCalculees.vars.id }}");
  687.     let climatDiv = document.querySelector(".form-group.col-md-4:has(#{{ form.climat.vars.id }})");
  688.     let stationMeteoDiv = document.querySelector(".form-group.col-md-3:has(#{{ form.stationmeteo.vars.id }})");
  689.     let stationAPIDiv = document.querySelector(".form-group.col-md-3:has(#{{ form.stationAPI.vars.id }})");
  690.     function updateVisibility() {
  691.         let anneesValue = anneesInput.value.trim(); // Récupère la valeur sélectionnée (1 ou 2)
  692.         if (anneesValue === "1") { 
  693.             // Si l'utilisateur sélectionne "2020 à 2024"
  694.             climatDiv.style.display = "none";
  695.             stationMeteoDiv.style.display = "none";
  696.             stationAPIDiv.style.display = "block";
  697.         } else if (anneesValue === "2") { 
  698.             // Si l'utilisateur sélectionne "2017 à 2022"
  699.             stationAPIDiv.style.display = "none";
  700.             climatDiv.style.display = "block";
  701.             stationMeteoDiv.style.display = "block";
  702.         } else {
  703.             // Tout afficher si aucune valeur correspondante
  704.             climatDiv.style.display = "block";
  705.             stationMeteoDiv.style.display = "block";
  706.             stationAPIDiv.style.display = "block";
  707.         }
  708.     }
  709.     // Appliquer les règles au chargement de la page
  710.     updateVisibility();
  711.     // Met à jour lors d'un changement dans le select
  712.     anneesInput.addEventListener("change", updateVisibility);
  713. });
  714. </script>
  715. </div>
  716. {% endblock %}