Guest User

Untitled

a guest
May 29th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.92 KB | None | 0 0
  1.             <!-- VERIFICATION DE CONNEXION -->
  2. <?php
  3. session_start();
  4. if (!isset($_SESSION['login']))
  5. {
  6.     header ('Location: index.php');
  7.     exit();
  8. }
  9. ?>
  10.             <!-- MANAGEMENT TABLE DISPLAY -->
  11. <?php
  12. ini_set ("display_errors",0);error_reporting(0);
  13. /* VARIABLE DECLARATION */
  14. $oui = 'OUI';
  15. $non = 'NON';
  16. $line = 4;
  17. $column = 0;
  18. $string_table = array();
  19. $column8 = 7;
  20. $column9 = 8;
  21. $line2 = 4;
  22. $size_table = 0;
  23. $index_percent = 0;
  24. $row = 1;
  25. $f = 0;
  26. $class1 = '';
  27. $class2 = '';
  28. $class3 = '';
  29. $class4 = '';
  30. $class5 = '';
  31. $class6 = '';
  32. $class7 = '';
  33. $class8 = '';
  34. $class9 = '';
  35. $class10 = '';
  36. $class11 = '';
  37. $check1 = '';
  38. $check2 = '';
  39. $Start_data = '';
  40. $Close_data = '';
  41. $Button = '';
  42. $name_radio = 1;
  43.  
  44. /* STOCK IN TABLE 'table_str' THE STRING OF CSV FILE */
  45. if (($handle = fopen("tes.csv", "r")) !== FALSE) {
  46.     while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
  47.         $num = count($data);
  48.         $row++;
  49.         for ($c=0; $c < $num; $c++)
  50.         {
  51.             $f++;
  52.             $table_str[$f] = explode(";", $data[$c]);
  53.         }  
  54.     }
  55.     /* COUNT LINE OF TABLE 'table_str' */
  56.     While (isset($table_str[$line2])==TRUE)
  57.     {
  58.         $size_table++;
  59.         $line2++;
  60.     }
  61.     /* DELETE CHAR '"' OF TABLE 'table_str' AND STOCK IN AN NEW OPTIMIZE TABLE2 'string_table' */
  62.     for ($h = 0; $h < $size_table; $h++)
  63.     {
  64.             for ($i = 0; $i <12; $i++)
  65.             {
  66.             $test = $table_str[$line][$column];
  67.             $test = strtok($test, '"');
  68.             $string_table[$h][$column] = $test;
  69.             $column++;
  70.             //$string_table = str_replace('"', '', $string_table);
  71.             }
  72.         $percentage[$index_percent] = strtok($string_table[$h][$column8], '%');
  73.         $index_percent++;
  74.         $percentage[$index_percent] = strtok($string_table[$h][$column9], '%');
  75.         $index_percent++;
  76.         $column = 0;
  77.         $line++;
  78.     }
  79.     //var_dump ($string_table);
  80.     fclose($handle);
  81. }
  82. ?>
  83. <!-- GUI -->
  84.     <html>
  85.     <head>
  86.         <meta charset="iso-8859-1">
  87.         <link href='https://fonts.googleapis.com/css?family=Orbitron:400,500,700,900' rel='stylesheet' type='text/css'>
  88.         <link rel="stylesheet" href="style.css" />
  89.         <title>Phase Test</title>
  90.     </head>
  91.  
  92.     <body>
  93.         <p class=var_sess><?php echo 'Bonjour '.$_SESSION['login'].''; ?></b><input type="submit" value="Déconnexion" onclick="self.location.href='deconnexion.php'"></input></p>
  94.         <p><img src='IMAGE/LOGO2.png' alt= "erreur logo"></img></p>
  95.         <p class="titre">Accès informations</p>
  96.         <br><br>
  97.         <table>                                 <!-- TABLE WATERING -->
  98.            
  99.             <caption>Tableau de contrôle des arroseurs</caption>
  100.            
  101.             <thead>         <!-- HEAD TABLE -->
  102.                 <tr>
  103.                     <th colspan="1" class=title1 ></th>
  104.                     <th colspan="4" class=title >ANOMALIES ARROSAGE</th>
  105.                     <th colspan="2" class=title >DETECTION ARROSAGE</th>
  106.                     <th colspan="2" class=title >NIVEAUX</th>
  107.                     <th colspan="6" class=title >ETAT ARROSAGE</th>
  108.                 </tr>
  109.                 <tr>
  110.                     <th class=subtitle >ARROSEURS</th>
  111.                    
  112.                     <th class=subtitle >BATTERIE</th>
  113.                     <th class=subtitle >PRESSION EAU</th>
  114.                     <th class=subtitle >ROTATION ENROULEUR</th>
  115.                     <th class=subtitle >FUITE</th>
  116.                    
  117.                     <th class=subtitle >PREMIER ANNEAU</th>
  118.                     <th class=subtitle >DEUXIEME ANNEAU</th>
  119.                    
  120.                     <th class=subtitle >EAU</th>
  121.                     <th class=subtitle >BATTERIE</th>
  122.                    
  123.                     <th class=subtitle >EN MARCHE</th>
  124.                     <th class=subtitle >EN ARRET</th>
  125.                     <th class=subtitle >EN PANNE</th>
  126.                     <th class=subtitle >DEMARRER/CONTINUER</th>
  127.                     <th class=subtitle >ARRÊTER</th>
  128.                     <th class=subtitle >VALIDER</th>
  129.                 </tr>
  130.             </thead>
  131.            
  132.             <tbody>         <!-- BODY TABLE -->
  133.             <?php
  134.             $index_percent = 0;
  135.             $Start_data = "<form action='script_validate.php' method='post'>";
  136.             $Close_data = "</form>";
  137.             $Button = "<input type='submit' name='Valider' value='Envoyer' Onclick='window.location='script_validate.php''></td>";
  138.             for($z = 0; $z < $size_table; $z++)
  139.             {
  140.                 if($string_table[$z][1] == 'OUI'){$class1 = 'class=red';}else{$class1 = 'class=green';}
  141.                 if($string_table[$z][2] == 'OUI'){$class2 = 'class=red';}else{$class2 = 'class=green';}
  142.                 if($string_table[$z][3] == 'OUI'){$class3 = 'class=red';}else{$class3 = 'class=green';}
  143.                 if($string_table[$z][4] == 'OUI'){$class4 = 'class=red';}else{$class4 = 'class=green';}
  144.                
  145.                 if($string_table[$z][5] == 'OUI'){$class5 = 'class=green';}else{$class5 = 'class=orange';}
  146.                 if($string_table[$z][6] == 'OUI'){$class6 = 'class=green';}else{$class6 = 'class=orange';}
  147.                
  148.                 if($percentage[$index_percent] <= 20){$class7 = 'class=red';} if(($percentage[$index_percent] >= 21)&&($percentage[$index_percent] <= 49)){$class7 = 'class=orange';}if($percentage[$index_percent] >= 50){$class7 = 'class=green';}
  149.                 $index_percent++;
  150.                 if($percentage[$index_percent] <= 20){$class8 = 'class=red';} if(($percentage[$index_percent] >= 21)&&($percentage[$index_percent] <= 49)){$class8 = 'class=orange';}if($percentage[$index_percent] >= 50){$class8 = 'class=green';}
  151.                 $index_percent++;
  152.                
  153.                 if($string_table[$z][9] == 'NON'){$class9 = 'class=orange';}else{$class9 = 'class=green';}
  154.                 if($string_table[$z][10] == 'NON'){$class10 = 'class=green';}else{$class10 = 'class=orange';}
  155.                 if($string_table[$z][11] == 'NON'){$class11 = 'class=green';}else{$class11 = 'class=red';}
  156.                
  157.                 if($string_table[$z][9] == 'OUI'){$check1 = 'checked="checked"';}else{$check1 = '';}
  158.                 if($string_table[$z][9] == 'NON'){$check2 = 'checked="checked"';}else{$check2 = '';}
  159.                
  160.                 echo "<tr>";
  161.                     echo "<td>",$string_table[$z][0],"</td>";
  162.  
  163.                     echo "<td ",$class1," >",$string_table[$z][1],"</td>";
  164.                     echo "<td ",$class2," >",$string_table[$z][2],"</td>";
  165.                     echo "<td ",$class3," >",$string_table[$z][3],"</td>";
  166.                     echo "<td ",$class4," >",$string_table[$z][4],"</td>";
  167.                    
  168.                     echo "<td ",$class5." >",$string_table[$z][5],"</td>";
  169.                     echo "<td ",$class6." >",$string_table[$z][6],"</td>";
  170.                    
  171.                     echo "<td ",$class7," >",$string_table[$z][7],"</td>";
  172.                     echo "<td ",$class8," >",$string_table[$z][8],"</td>";
  173.                    
  174.                     echo "<td ",$class9," >",$string_table[$z][9],"</td>";
  175.                     echo "<td ",$class10," >",$string_table[$z][10],"</td>";
  176.                     echo "<td ",$class11," >",$string_table[$z][11],"</td>";
  177.                    
  178.                     if($z == 0){echo $Start_data;}
  179.                    
  180.                     echo "<td><input type='radio' name='radio_",$name_radio,"' value='OUI' ",$check1," ></td>";
  181.                     echo "<td><input type='radio' name='radio_",$name_radio,"' value='NON' ",$check2," ></td>";
  182.                     $name_radio++;
  183.                    
  184.                     if($z == 0){echo "<td rowspan=",$size_table," >",$Button;}
  185.                    
  186.                     if(($z+1) == $size_table){echo $Close_data;}
  187.                    
  188.                     if($z == 0){echo "<input type='hidden' name='size' value='",$size_table,"'></td>";}
  189.                    
  190.                 echo "</tr>";
  191.             }
  192.             ?>
  193.             </tbody>
  194.            
  195.             <tfoot>         <!-- FEET TABLE -->
  196.            
  197.             </tfoot>
  198.         </table>
  199.         <h3>Légende :&nbsp;<span class=green >&nbsp;Vert : Aucune Anomalie</span>&nbsp;<span class=orange>Orange : Traitement en cours/ Anomalie mineure</span>&nbsp;<span class=red>Rouge : Anomalie majeure</span>
  200.     </body>
  201.     </html>
Add Comment
Please, Sign In to add comment