course_access_details.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * @author Thomas Depraetere
  5. * @author Hugues Peeters
  6. * @author Christophe Gesche
  7. * @author Sebastien Piraux
  8. *
  9. * @package chamilo.tracking
  10. */
  11. /**
  12. * Code
  13. */
  14. // TODO: Is this file deprecated?
  15. /*
  16. INIT SECTION
  17. */
  18. $reqdate = $_REQUEST['reqdate'];
  19. $period = $_REQUEST['period'];
  20. $displayType = $_REQUEST['displayType'];
  21. // name of the language file that needs to be included
  22. $language_file = "tracking";
  23. require_once '../inc/global.inc.php';
  24. $interbreadcrumb[]= array ("url"=>"courseLog.php", "name"=> get_lang('ToolName'));
  25. $nameTools = get_lang('TrafficDetails');
  26. $htmlHeadXtra[] = "<style type='text/css'>
  27. /*<![CDATA[*/
  28. .secLine {background-color : #E6E6E6;}
  29. .content {padding-left : 15px;padding-right : 15px; }
  30. .specialLink{color : #0000FF;}
  31. /*]]>*/
  32. </style>
  33. <style media='print' type='text/css'>
  34. /*<![CDATA[*/
  35. td {border-bottom: thin dashed gray;}
  36. /*]]>*/
  37. </style>";
  38. //@todo use Database library
  39. $TABLETRACK_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
  40. Display::display_header($nameTools,"Tracking");
  41. require_once api_get_path(LIBRARY_PATH)."statsUtils.lib.inc.php";
  42. // the variables for the days and the months
  43. // Defining the shorts for the days
  44. $DaysShort = api_get_week_days_short();
  45. // Defining the days of the week to allow translation of the days
  46. $DaysLong = api_get_week_days_long();
  47. // Defining the months of the year to allow translation of the months
  48. $MonthsLong = api_get_months_long();
  49. $is_allowedToTrack = $is_courseAdmin;
  50. ?>
  51. <h3>
  52. <?php echo $nameTools ?>
  53. </h3>
  54. <table width="100%" cellpadding="2" cellspacing="3" border="0">
  55. <?php
  56. if ($is_allowedToTrack)
  57. {
  58. if( !isset($reqdate) || $reqdate < 0 || $reqdate > 2149372861 )
  59. $reqdate = time();
  60. //** dislayed period
  61. echo "<tr><td><b>";
  62. switch($period)
  63. {
  64. case "year" :
  65. echo date(" Y", $reqdate);
  66. break;
  67. case "month" :
  68. echo $MonthsLong[date("n", $reqdate)-1].date(" Y", $reqdate);
  69. break;
  70. // default == day
  71. default :
  72. $period = "day";
  73. case "day" :
  74. echo $DaysLong[date("w" , $reqdate)].date(" d " , $reqdate).$MonthsLong[date("n", $reqdate)-1].date(" Y" , $reqdate);
  75. break;
  76. }
  77. echo "</b></tr></td>";
  78. //** menu
  79. echo "<tr>
  80. <td>
  81. ";
  82. echo " ".get_lang('PeriodToDisplay')." : [<a href='".api_get_self()."?period=year&reqdate=$reqdate' class='specialLink'>".get_lang('PeriodYear')."</a>]
  83. [<a href='".api_get_self()."?period=month&reqdate=$reqdate' class='specialLink'>".get_lang('PeriodMonth')."</a>]
  84. [<a href='".api_get_self()."?period=day&reqdate=$reqdate' class='specialLink'>".get_lang('PeriodDay')."</a>]
  85. &nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;
  86. ".get_lang('DetailView')." :
  87. ";
  88. switch($period)
  89. {
  90. case "year" :
  91. //-- if period is "year" display can be by month, day or hour
  92. echo " [<a href='".api_get_self()."?period=$period&reqdate=$reqdate&displayType=month' class='specialLink'>".get_lang('PeriodMonth')."</a>]";
  93. case "month" :
  94. //-- if period is "month" display can be by day or hour
  95. echo " [<a href='".api_get_self()."?period=$period&reqdate=$reqdate&displayType=day' class='specialLink'>".get_lang('PeriodDay')."</a>]";
  96. case "day" :
  97. //-- if period is "day" display can only be by hour
  98. echo " [<a href='".api_get_self()."?period=$period&reqdate=$reqdate&displayType=hour' class='specialLink'>".get_lang('PeriodHour')."</a>]";
  99. break;
  100. }
  101. echo "&nbsp;&nbsp;&nbsp;||&nbsp;&nbsp;&nbsp;";
  102. switch($period)
  103. {
  104. case "year" :
  105. // previous and next date must be evaluated
  106. // 30 days should be a good approximation
  107. $previousReqDate = mktime(1,1,1,1,1,date("Y",$reqdate)-1);
  108. $nextReqDate = mktime(1,1,1,1,1,date("Y",$reqdate)+1);
  109. echo "
  110. [<a href='".api_get_self()."?period=$period&reqdate=$previousReqDate&displayType=$displayType' class='specialLink'>".get_lang('PreviousYear')."</a>]
  111. [<a href='".api_get_self()."?period=$period&reqdate=$nextReqDate&displayType=$displayType' class='specialLink'>".get_lang('NextYear')."</a>]
  112. ";
  113. break;
  114. case "month" :
  115. // previous and next date must be evaluated
  116. // 30 days should be a good approximation
  117. $previousReqDate = mktime(1,1,1,date("m",$reqdate)-1,1,date("Y",$reqdate));
  118. $nextReqDate = mktime(1,1,1,date("m",$reqdate)+1,1,date("Y",$reqdate));
  119. echo "
  120. [<a href='".api_get_self()."?period=$period&reqdate=$previousReqDate&displayType=$displayType' class='specialLink'>".get_lang('PreviousMonth')."</a>]
  121. [<a href='".api_get_self()."?period=$period&reqdate=$nextReqDate&displayType=$displayType' class='specialLink'>".get_lang('NextMonth')."</a>]
  122. ";
  123. break;
  124. case "day" :
  125. // previous and next date must be evaluated
  126. $previousReqDate = $reqdate - 86400;
  127. $nextReqDate = $reqdate + 86400;
  128. echo "
  129. [<a href='".api_get_self()."?period=$period&reqdate=$previousReqDate&displayType=$displayType' class='specialLink'>".get_lang('PreviousDay')."</a>]
  130. [<a href='".api_get_self()."?period=$period&reqdate=$nextReqDate&displayType=$displayType' class='specialLink'>".get_lang('NextDay')."</a>]
  131. ";
  132. break;
  133. }
  134. echo "
  135. </td>
  136. </tr>
  137. ";
  138. //**
  139. // display information about this period
  140. switch($period)
  141. {
  142. // all days
  143. case "year" :
  144. $sql = "SELECT UNIX_TIMESTAMP( access_date )
  145. FROM $TABLETRACK_ACCESS
  146. WHERE YEAR( access_date ) = YEAR( FROM_UNIXTIME( '$reqdate' ) )
  147. AND access_cours_code = '$_cid'
  148. AND access_tool IS NULL ";
  149. if($displayType == "month")
  150. {
  151. $sql .= "ORDER BY UNIX_TIMESTAMP( access_date)";
  152. $month_array = monthTab($sql);
  153. makeHitsTable($month_array,get_lang('PeriodMonth'));
  154. }
  155. elseif($displayType == "day")
  156. {
  157. $sql .= "ORDER BY DAYOFYEAR( access_date)";
  158. $days_array = daysTab($sql);
  159. makeHitsTable($days_array,get_lang('PeriodDay'));
  160. }
  161. else // by hours by default
  162. {
  163. $sql .= "ORDER BY HOUR( access_date)";
  164. $hours_array = hoursTab($sql);
  165. makeHitsTable($hours_array,get_lang('PeriodHour'));
  166. }
  167. break;
  168. // all days
  169. case "month" :
  170. $sql = "SELECT UNIX_TIMESTAMP( access_date )
  171. FROM $TABLETRACK_ACCESS
  172. WHERE MONTH(access_date) = MONTH (FROM_UNIXTIME( '$reqdate' ) )
  173. AND YEAR( access_date ) = YEAR( FROM_UNIXTIME( '$reqdate' ) )
  174. AND access_cours_code = '$_cid'
  175. AND access_tool IS NULL ";
  176. if($displayType == "day")
  177. {
  178. $sql .= "ORDER BY DAYOFYEAR( access_date)";
  179. $days_array = daysTab($sql);
  180. makeHitsTable($days_array,get_lang('PeriodDay'));
  181. }
  182. else // by hours by default
  183. {
  184. $sql .= "ORDER BY HOUR( access_date)";
  185. $hours_array = hoursTab($sql);
  186. makeHitsTable($hours_array,get_lang('PeriodHour'));
  187. }
  188. break;
  189. // all hours
  190. case "day" :
  191. $sql = "SELECT UNIX_TIMESTAMP( access_date )
  192. FROM $TABLETRACK_ACCESS
  193. WHERE DAYOFMONTH(access_date) = DAYOFMONTH(FROM_UNIXTIME( '$reqdate' ) )
  194. AND MONTH(access_date) = MONTH (FROM_UNIXTIME( '$reqdate' ) )
  195. AND YEAR( access_date ) = YEAR( FROM_UNIXTIME( '$reqdate' ) )
  196. AND access_cours_code = '$_cid'
  197. AND access_tool IS NULL
  198. ORDER BY HOUR( access_date )";
  199. $hours_array = hoursTab($sql,$reqdate);
  200. makeHitsTable($hours_array,get_lang('PeriodHour'));
  201. break;
  202. }
  203. }
  204. else // not allowed to track
  205. {
  206. api_not_allowed();
  207. }
  208. ?>
  209. </table>
  210. <?php
  211. Display::display_footer();