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 $this->
addColumn($lng->txt(
"object_id"),
"obj_id");
37 for($loop = 0; $loop<24; $loop+=2)
39 $this->
addColumn(str_pad($loop, 2,
"0", STR_PAD_LEFT).
":00-<br />".
40 str_pad($loop+2, 2,
"0", STR_PAD_LEFT).
":00 ",
"hour".$loop,
"",
false,
"ilRight");
42 $this->
addColumn($lng->txt(
"total"),
"sum",
"",
false,
"ilRight");
44 $this->
setTitle($this->lng->txt(
"trac_object_stat_daily"));
51 $this->
setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
52 $this->
setRowTemplate(
"tpl.lp_object_statistics_daily_row.html",
"Services/Tracking");
69 if($a_field !=
"title")
86 include_once(
"./Services/Form/classes/class.ilSelectInputGUI.php");
90 $si->readFromSession();
95 $this->filter[
"type"] =
$si->getValue();
98 include_once(
"./Services/Form/classes/class.ilTextInputGUI.php");
99 $ti =
new ilTextInputGUI($lng->txt(
"trac_title_description"),
"query");
103 $ti->readFromSession();
104 $this->filter[
"query"] = $ti->getValue();
108 $si->setOptions(array(
"read_count"=>$lng->txt(
"trac_read_count"),
109 "spent_seconds"=>$lng->txt(
"trac_spent_seconds")));
111 $si->readFromSession();
114 $si->setValue(
"read_count");
116 $this->filter[
"measure"] =
$si->getValue();
122 $si->readFromSession();
125 $si->setValue(date(
"Y-m"));
127 $this->filter[
"yearmonth"] =
$si->getValue();
137 include_once
"Services/Tracking/classes/class.ilTrQuery.php";
139 $yearmonth = explode(
"-", $this->filter[
"yearmonth"]);
140 if(
sizeof($yearmonth) == 1)
149 foreach($stat_objects as $obj_id => $hours)
151 $data[$obj_id][
"obj_id"] = $obj_id;
154 foreach($hours as $hour => $values)
157 $data[$obj_id][
"hour".floor($hour/2)*2] += (int)$values[$this->filter[
"measure"]];
158 $data[$obj_id][
"sum"] += (int)$values[$this->filter[
"measure"]];
161 $data[$obj_id][
"graph"][
"hour".$hour] = $values[$this->filter[
"measure"]];
166 foreach($objects as $obj_id => $ref_ids)
168 if(!isset(
$data[$obj_id]))
170 $data[$obj_id][
"obj_id"] = $obj_id;
188 $this->tpl->setVariable(
"OBJ_ID", $a_set[
"obj_id"]);
190 $this->tpl->setVariable(
"ICON_ALT", $this->lng->txt($type));
191 $this->tpl->setVariable(
"TITLE_TEXT", $a_set[
"title"]);
193 if($this->preselected && in_array($a_set[
"obj_id"], $this->preselected))
195 $this->tpl->setVariable(
"CHECKBOX_STATE",
" checked=\"checked\"");
198 $this->tpl->setCurrentBlock(
"hour");
199 for($loop = 0; $loop<24; $loop+=2)
201 $value = (int)$a_set[
"hour".$loop];
202 if($this->filter[
"measure"] !=
"spent_seconds")
210 $this->tpl->setVariable(
"HOUR_VALUE", $value);
211 $this->tpl->parseCurrentBlock();
214 if($this->filter[
"measure"] ==
"spent_seconds")
222 $this->tpl->setVariable(
"TOTAL", $sum);
229 include_once
"Services/Chart/classes/class.ilChart.php";
230 $chart =
new ilChart(
"objstdly", 700, 500);
233 $chart->setLegend($legend);
236 foreach($this->
getData() as $object)
238 if(in_array($object[
"obj_id"], $a_graph_items))
243 for($loop = 0; $loop<24; $loop++)
245 $value = (int)$object[
"graph"][
"hour".$loop];
246 $max_value = max($max_value, $value);
247 if($this->filter[
"measure"] !=
"spent_seconds")
251 $series->addPoint($loop, $value);
254 $chart->addData($series);
258 $value_ticks = $this->
buildValueScale($max_value, ($this->filter[
"measure"] !=
"spent_seconds"),
259 ($this->filter[
"measure"] ==
"spent_seconds"));
262 for($loop = 0; $loop<24; $loop++)
264 $labels[$loop] = str_pad($loop, 2,
"0", STR_PAD_LEFT);
266 $chart->setTicks($labels, $value_ticks,
true);
268 return $chart->getHTML();
279 $a_worksheet->write($a_row, 0, $a_set[
"obj_id"]);
282 for($loop = 0; $loop<24; $loop+=2)
284 $value = (int)$a_set[
"hour".$loop];
285 if($this->filter[
"measure"] !=
"spent_seconds")
291 $a_worksheet->write($a_row, $col, $value);
294 if($this->filter[
"measure"] ==
"spent_seconds")
298 $sum = (int)$a_set[
"sum"];
305 $a_worksheet->write($a_row, $col, $sum);
316 $a_csv->addColumn($a_set[
"obj_id"]);
318 for($loop = 0; $loop<24; $loop+=2)
320 $value = (int)$a_set[
"hour".$loop];
321 if($this->filter[
"measure"] !=
"spent_seconds")
326 $a_csv->addColumn($value);
329 if($this->filter[
"measure"] ==
"spent_seconds")
333 $sum = (int)$a_set[
"sum"];
339 $a_csv->addColumn($sum);