generic.reports.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. $reports_template['Generic'] = array(
  3. 'description' => 'Generic',
  4. 'getSQL' => 'reports_template_Generic_getSQL',
  5. 'wizard' =>
  6. '
  7. <span id="Generic" class="step">
  8. <span class="font_normal_07em_black">This report does not need any particular settings</span><br />
  9. <input type="hidden" class="link" value="format" />
  10. </span>
  11. ');
  12. function reports_template_Generic_getSQL() {
  13. // settings
  14. // Nom, prenom
  15. $query = 'select u.lastname as "Last name", u.firstname as "First name" ';
  16. $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
  17. $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
  18. $query .= ' order by u.user_id ';
  19. $queries[0] = $query;
  20. // Custom Field
  21. foreach (array(10 => "description") as $k => $v) {
  22. $query = 'select ufv.value as "'.$v.'" ';
  23. $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
  24. $query .= 'left outer join '.Database::get_main_table(TABLE_EXTRA_FIELD_VALUES).' ufv ';
  25. $query .= ' on ufv.item_id = u.user_id and ufv.field_id = '.$k;
  26. $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
  27. $query .= ' order by u.user_id ';
  28. $queries[] = $query;
  29. }
  30. // Stored Value
  31. $sv = array();
  32. foreach ($sv as $k => $v) {
  33. $query = 'select sec_to_time(sv.sv_value) as "'.$v.'" ';
  34. $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
  35. $query .= ' left outer join '.Database::get_main_table(TABLE_TRACK_STORED_VALUES).' sv ';
  36. $query .= 'on sv.user_id = u.user_id and sv_key = "'.$k.'" ';
  37. $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
  38. $query .= ' order by u.user_id ';
  39. $queries[] = $query;
  40. }
  41. // premiere connexion
  42. $query = 'select min(tel.login_date) as "First connection", max(tel.logout_date) as "Latest connection" ';
  43. $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
  44. $query .= 'left outer join '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN).' tel ';
  45. $query .= ' on tel.login_user_id = u.user_id ';
  46. $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
  47. $query .= ' group by u.user_id ';
  48. $query .= ' order by u.user_id ';
  49. $queries[] = $query;
  50. return $queries;
  51. }