forked from mmitura/report
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreport_controller.php
More file actions
48 lines (36 loc) · 1.63 KB
/
report_controller.php
File metadata and controls
48 lines (36 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
/*
All Emoncms code is released under the GNU Affero General Public License.
See COPYRIGHT.txt and LICENSE.txt.
---------------------------------------------------------------------
Emoncms - open source energy visualisation
Part of the OpenEnergyMonitor project:
http://openenergymonitor.org
*/
// no direct access
defined('EMONCMS_EXEC') or die('Restricted access');
function report_controller()
{
global $mysqli, $session, $route;
$result = false;
require "Modules/report/report_model.php";
$report = new Report($mysqli);
require "Modules/report/applist_model.php";
$applist = new AppList($mysqli);
if ($route->format == 'html' && $session['write'])
{
if ($route->action == 'electric') $result = view("Modules/report/electric.php", array());
//if ($route->action == 'applist') $result = view("Modules/report/applist.php", array());
}
if ($route->format == 'json' && $session['write'])
{
if ($route->action == 'setsettings') $result = $report->set_settings($session['userid'],get('settings'));
if ($route->action == 'getsettings') $result = $report->get_settings($session['userid']);
if ($route->action == 'getlists') $result = $applist->get_lists($session['userid']);
if ($route->action == 'getapplist') $result = $applist->get($session['userid'],get('id'));
if ($route->action == 'setapplist') $result = $applist->set($session['userid'],get('id'),get('name'),get('list'));
if ($route->action == 'deleteapplist') $result = $applist->delete($session['userid'],get('id'));
}
return array('content'=>$result);
}
?>