summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics_reporting
diff options
context:
space:
mode:
authorChristian Hofmaier2017-01-17 13:04:13 +0100
committerChristian Hofmaier2017-01-17 13:04:13 +0100
commit4badbadf0131bf6b4b62d8e337ff6020e66b35ff (patch)
tree2b629aceef2f8615b6feb553767627eba386426c /modules-available/statistics_reporting
parent[statistics_reporting] added ui to disable the reporting (diff)
downloadslx-admin-4badbadf0131bf6b4b62d8e337ff6020e66b35ff.tar.gz
slx-admin-4badbadf0131bf6b4b62d8e337ff6020e66b35ff.tar.xz
slx-admin-4badbadf0131bf6b4b62d8e337ff6020e66b35ff.zip
[statistics_reporting] added cronjob for weekly report
Diffstat (limited to 'modules-available/statistics_reporting')
-rw-r--r--modules-available/statistics_reporting/hooks/cron.inc.php34
1 files changed, 33 insertions, 1 deletions
diff --git a/modules-available/statistics_reporting/hooks/cron.inc.php b/modules-available/statistics_reporting/hooks/cron.inc.php
index b79883df..57e64a84 100644
--- a/modules-available/statistics_reporting/hooks/cron.inc.php
+++ b/modules-available/statistics_reporting/hooks/cron.inc.php
@@ -1,3 +1,35 @@
<?php
-$lastReporting = Property::get("lastReporting", 7);
+$nextReporting = Property::get("nextReporting", 0);
+$time = time();
+
+$allowReport = Property::get("reportingStatus", "on") == "on";
+
+if ($nextReporting < $time && $allowReport) {
+
+ Property::set("nextReporting", strtotime("Sunday 23:59:59"));
+
+ GetData::$from = strtotime("Monday last week");
+ GetData::$to = strtotime("Sunday last week 23:59:59");
+
+ $data = array_merge(GetData::total(true), array('perLocation' => array(), 'perClient' => array(), 'perUser' => array(), 'perVM' => array()));
+ $data['perLocation'] = GetData::perLocation(true);
+ $data['perClient'] = GetData::perClient(true);
+ $data['perUser'] = GetData::perUser(true);
+ $data['perVM'] = GetData::perVM();
+
+
+ $statisticsReport = json_encode($data);
+
+ $url = CONFIG_REPORTING_URL;
+
+ $curl = curl_init($url);
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
+ curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
+ curl_setopt($curl, CURLOPT_POST, true);
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $statisticsReport);
+
+ $json_response = curl_exec($curl);
+
+ curl_close($curl);
+}