/gespac/gestion_inventaire/voir_membres-marque_stype.php

http://gespac.googlecode.com/ · PHP · 96 lines · 87 code · 8 blank · 1 comment · 0 complexity · aadd529bcb7b2a6468392e3f95f984a1 MD5 · raw file

  1. <!--
  2. Liste des membres d'un SOUS TYPE particulier
  3. -->
  4. <?PHP
  5. // lib
  6. require_once ('../fonctions.php');
  7. include_once ('../config/databases.php');
  8. include_once ('../../class/Log.class.php');
  9. include_once ('../../class/Sql.class.php');
  10. // libellé du type de marque récupéré de la page voir_marques.php
  11. $marque_stype = $_GET ['marque_stype'];
  12. // cnx ŕ la base de données GESPAC
  13. $con_gespac = new Sql ($host, $user, $pass, $gespac);
  14. // stockage des lignes retournées par sql dans un tableau nommé avec originalité "array" (mais "tableau" peut aussi marcher)
  15. $liste_des_materiels = $con_gespac->QueryAll ( "SELECT mat_nom, mat_dsit, mat_serial, mat_etat, marque_marque, marque_model, marque_type, marque_stype, mat_id FROM materiels, marques WHERE materiels.marque_id = marques.marque_id AND marque_stype='$marque_stype' order by mat_nom" );
  16. echo "<p><small>" . count($liste_des_materiels) . " matériel(s).</small></p>";
  17. $fp = fopen('../dump/extraction.csv', 'w+'); //Ouverture du fichier
  18. fputcsv($fp, array('nom', 'dsit', 'serial', 'etat', 'marque', 'modele', 'type'), ',' ); // ENTETES
  19. echo "<center><a href='./dump/extraction.csv' target=_blank>fichier CSV</a></center><br>";
  20. ?>
  21. <center>
  22. <table id="myTable" width=620>
  23. <th>nom</th>
  24. <th>dsit</th>
  25. <th>serial</th>
  26. <th>etat</th>
  27. <th>marque</th>
  28. <th>modčle</th>
  29. <th>type</th>
  30. <?PHP
  31. $compteur = 0;
  32. // On parcourt le tableau
  33. foreach ($liste_des_materiels as $record ) {
  34. // On écrit les lignes en brut dans la page html
  35. // alternance des couleurs
  36. $tr_class = ($compteur % 2) == 0 ? "tr3" : "tr4";
  37. echo "<tr class=$tr_class>";
  38. $nom = $record['mat_nom'];
  39. $dsit = $record['mat_dsit'];
  40. $serial = $record['mat_serial'];
  41. $etat = $record['mat_etat'];
  42. $marque = $record['marque_marque'];
  43. $model = $record['marque_model'];
  44. $type = $record['marque_type'];
  45. $stype = $record['marque_stype'];
  46. $id = $record['mat_id'];
  47. //echo "<td> $nom </td>";
  48. echo "<td> $nom </td>";
  49. echo "<td> $dsit </td>";
  50. echo "<td> $serial </td>";
  51. echo "<td> $etat </td>";
  52. echo "<td> $marque </td>";
  53. echo "<td> $model </td>";
  54. echo "<td> $type </td>";
  55. echo "</tr>";
  56. // On constitue le fichier CSV de l'extraction
  57. fputcsv($fp, array($nom, $dsit, $serial, $etat, $marque, $model, $type), ',');
  58. $compteur++;
  59. }
  60. fclose($fp);
  61. ?>
  62. </table>
  63. </center>
  64. <br>
  65. <?PHP
  66. // On se déconnecte de la db
  67. $con_gespac->Close();
  68. ?>