4 include_once(
"./Services/Tracking/classes/class.ilLPTableBaseGUI.php");
20 function __construct($a_parent_obj, $a_parent_cmd, array $a_preselect = null, $a_load_items =
true)
24 $this->preselected = $a_preselect;
26 $this->
setId(
"lpobjstatdlytbl");
35 $this->
addColumn($lng->txt(
"trac_title"),
"title");
36 for($loop = 0; $loop<24; $loop+=2)
38 $this->
addColumn(str_pad($loop, 2,
"0", STR_PAD_LEFT).
":00-<br />".
39 str_pad($loop+2, 2,
"0", STR_PAD_LEFT).
":00 ",
"hour".$loop,
"",
false,
"ilRight");
41 $this->
addColumn($lng->txt(
"total"),
"sum",
"",
false,
"ilRight");
43 $this->
setTitle($this->lng->txt(
"trac_object_stat_daily"));
50 $this->
setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
51 $this->
setRowTemplate(
"tpl.lp_object_statistics_daily_row.html",
"Services/Tracking");
60 include_once(
"./Services/Tracking/classes/class.ilLPObjSettings.php");
61 include_once
"Services/Tracking/classes/class.ilTrQuery.php";
65 $link =
" <a href=\"".$ilCtrl->getLinkTarget($a_parent_obj,
"admin").
"\">»".
66 $lng->txt(
"trac_log_info_link").
"</a>";
67 ilUtil::sendInfo(sprintf($lng->txt(
"trac_log_info"), $info_date, $info[
"counter"]).$link);
79 for($loop = 0; $loop<24; $loop+=2)
81 $fields[] =
"hour".$loop;
84 if(in_array($a_field, $fields))
101 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
105 $si->readFromSession();
108 $si->setValue(
"crs");
110 $this->filter[
"type"] = $si->getValue();
113 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
114 $ti =
new ilTextInputGUI($lng->txt(
"trac_title_description"),
"query");
118 $ti->readFromSession();
119 $this->filter[
"query"] = $ti->getValue();
123 $si->
setOptions(array(
"read_count"=>$lng->txt(
"trac_read_count"),
124 "spent_seconds"=>$lng->txt(
"trac_spent_seconds")));
126 $si->readFromSession();
129 $si->setValue(
"read_count");
131 $this->filter[
"measure"] = $si->getValue();
134 $si =
new ilSelectInputGUI($lng->txt(
"year").
" / ".$lng->txt(
"month"),
"yearmonth");
136 for($loop = 0; $loop < 10; $loop++)
138 $year = date(
"Y")-$loop;
139 $options[$year] = $year;
140 for($loop2 = 12; $loop2 > 0; $loop2--)
142 $month = str_pad($loop2, 2,
"0", STR_PAD_LEFT);
143 if($year.$month <= date(
"Ym"))
145 $options[$year.
"-".$month] = $year.
" / ".
146 $lng->txt(
"month_".$month.
"_long");
152 $si->readFromSession();
155 $si->setValue(date(
"Y-m"));
157 $this->filter[
"yearmonth"] = $si->getValue();
167 include_once
"Services/Tracking/classes/class.ilTrQuery.php";
169 $yearmonth = explode(
"-", $this->filter[
"yearmonth"]);
170 if(
sizeof($yearmonth) == 1)
179 foreach($stat_objects as $obj_id => $hours)
181 $data[$obj_id][
"obj_id"] = $obj_id;
184 foreach($hours as $hour => $values)
187 $data[$obj_id][
"hour".floor($hour/2)*2] += (int)$values[$this->filter[
"measure"]];
188 $data[$obj_id][
"sum"] += (int)$values[$this->filter[
"measure"]];
191 $data[$obj_id][
"graph"][
"hour".$hour] = $values[$this->filter[
"measure"]];
196 foreach($objects as $obj_id => $ref_ids)
198 if(!isset(
$data[$obj_id]))
200 $data[$obj_id][
"obj_id"] = $obj_id;
218 $this->tpl->setVariable(
"OBJ_ID", $a_set[
"obj_id"]);
220 $this->tpl->setVariable(
"ICON_ALT", $this->lng->txt($type));
221 $this->tpl->setVariable(
"TITLE_TEXT", $a_set[
"title"]);
223 if($this->preselected && in_array($a_set[
"obj_id"], $this->preselected))
225 $this->tpl->setVariable(
"CHECKBOX_STATE",
" checked=\"checked\"");
228 $this->tpl->setCurrentBlock(
"hour");
229 for($loop = 0; $loop<24; $loop+=2)
231 $value = (int)$a_set[
"hour".$loop];
232 if($this->filter[
"measure"] ==
"read_count")
236 else if($this->filter[
"measure"] ==
"spent_seconds")
240 $this->tpl->setVariable(
"HOUR_VALUE", $value);
241 $this->tpl->parseCurrentBlock();
244 if($this->filter[
"measure"] ==
"spent_seconds")
252 $this->tpl->setVariable(
"TOTAL", $sum);
259 include_once
"Services/Chart/classes/class.ilChart.php";
260 $chart =
new ilChart(
"objstdly", 700, 500);
266 foreach($this->
getData() as $object)
268 if(in_array($object[
"obj_id"], $a_graph_items))
273 for($loop = 0; $loop<24; $loop++)
275 $value = (int)$object[
"graph"][
"hour".$loop];
276 $max_value = max($max_value, $value);
277 if($this->filter[
"measure"] ==
"read_count")
281 $series->addPoint($loop, $value);
284 $chart->addData($series);
288 $value_ticks = $this->
buildValueScale($max_value, ($this->filter[
"measure"] ==
"read_count"),
289 ($this->filter[
"measure"] ==
"spent_seconds"));
292 for($loop = 0; $loop<24; $loop++)
294 $labels[$loop] = str_pad($loop, 2,
"0", STR_PAD_LEFT);
296 $chart->setTicks($labels, $value_ticks,
true);
298 return $chart->getHTML();
311 for($loop = 0; $loop<24; $loop+=2)
313 $value = (int)$a_set[
"hour".$loop];
314 if($this->filter[
"measure"] ==
"read_count")
318 else if($this->filter[
"measure"] ==
"spent_seconds")
325 $a_worksheet->write($a_row, $col, $value);
328 if($this->filter[
"measure"] ==
"spent_seconds")
332 $sum = (int)$a_set[
"sum"];
339 $a_worksheet->write($a_row, $col, $sum);
351 for($loop = 0; $loop<24; $loop+=2)
353 $value = (int)$a_set[
"hour".$loop];
354 if($this->filter[
"measure"] ==
"read_count")
358 else if($this->filter[
"measure"] ==
"spent_seconds")
364 $a_csv->addColumn($value);
367 if($this->filter[
"measure"] ==
"spent_seconds")
371 $sum = (int)$a_set[
"sum"];
377 $a_csv->addColumn($sum);