generic.reports.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. );
  13. function reports_template_Generic_getSQL()
  14. {
  15. // settings
  16. // Nom, prenom
  17. $query = 'select u.lastname as "Last name", u.firstname as "First name" ';
  18. $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
  19. $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
  20. $query .= ' order by u.user_id ';
  21. $queries[0] = $query;
  22. // Custom Field
  23. foreach (array(10 => "description") as $k => $v) {
  24. $query = 'select ufv.value as "'.$v.'" ';
  25. $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
  26. $query .= 'left outer join '.Database::get_main_table(TABLE_EXTRA_FIELD_VALUES).' ufv ';
  27. $query .= ' on ufv.item_id = u.user_id and ufv.field_id = '.$k;
  28. $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
  29. $query .= ' order by u.user_id ';
  30. $queries[] = $query;
  31. }
  32. // Stored Value
  33. $sv = array();
  34. foreach ($sv as $k => $v) {
  35. $query = 'select sec_to_time(sv.sv_value) as "'.$v.'" ';
  36. $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
  37. $query .= ' left outer join '.Database::get_main_table(TABLE_TRACK_STORED_VALUES).' sv ';
  38. $query .= 'on sv.user_id = u.user_id and sv_key = "'.$k.'" ';
  39. $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
  40. $query .= ' order by u.user_id ';
  41. $queries[] = $query;
  42. }
  43. // premiere connexion
  44. $query = 'select min(tel.login_date) as "First connection", max(tel.logout_date) as "Latest connection" ';
  45. $query .= 'from '.Database::get_main_table(TABLE_MAIN_USER).' u ';
  46. $query .= 'left outer join '.Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN).' tel ';
  47. $query .= ' on tel.login_user_id = u.user_id ';
  48. $query .= ' where u.user_id in ('.reports_getVisibilitySQL().') ';
  49. $query .= ' group by u.user_id ';
  50. $query .= ' order by u.user_id ';
  51. $queries[] = $query;
  52. return $queries;
  53. }