2
0

cms.event-export-inscription.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. error_reporting(E_ALL);
  3. ini_set("display_errors", 1);
  4. if (core::ifGet("from") AND core::getGet("from") == "event-export-inscription") {
  5. db::query("SELECT "
  6. . "" . DB_T_SALARIES . ".id, "
  7. . "" . DB_T_SALARIES . ".loginId, "
  8. . "" . DB_T_SALARIES . ".nom, "
  9. . "" . DB_T_SALARIES . ".prenom, "
  10. . "" . DB_T_SALARIES . ".sexe, "
  11. . "" . DB_T_SALARIES . ".contrat, "
  12. . "" . DB_T_SALARIES . ".lieu, "
  13. . "" . DB_T_SALARIES . ".actif, "
  14. . "" . DB_T_EVENTS_INSCRITS . ".id_evenement, "
  15. . "" . DB_T_EVENTS_INSCRITS . ".present "
  16. . "FROM " . DB_T_SALARIES . " "
  17. . "INNER JOIN " . DB_T_EVENTS_INSCRITS . " ON " . DB_T_EVENTS_INSCRITS . ".id_salarie = " . DB_T_SALARIES . ".id "
  18. . "WHERE " . DB_T_EVENTS_INSCRITS . ".id_evenement = " . core::getGet("id"));
  19. $row = db::resultset();
  20. $tmpList = 'inscripts-evenement-' . core::getGet("id") . '.csv';
  21. $csv = fopen(DIR_TEMP . $tmpList , 'w');
  22. fputcsv($csv, array("id", "loginId", "nom", "prenom", "sexe", "contrat", "lieu", "actif", "id_evenement", "present"), ";");
  23. foreach ($row as $fields) {
  24. fputcsv($csv, $fields, ";");
  25. }
  26. fclose($csv);
  27. header('Content-type: application/octet-stream;');
  28. header('Content-Transfer-Encoding: base64');
  29. header('Content-Disposition: attachment; filename="'.$tmpList.'"');
  30. readfile(DIR_TEMP . $tmpList);
  31. unlink(DIR_TEMP.$tmpList);
  32. } else {
  33. header('HTTP/1.0 401 Unauthorized');
  34. exit();
  35. }