예제 #1
0
<?php

require_once __DIR__ . "/bootstrap.php";
$sql = new \sql\Database();
$report = null;
if (isset($_GET['report'])) {
    $report = \reports\Report::get($_GET['report']);
    $sql->selectDB(\util\Config::$database->tablesDB);
    $report->run($sql);
} else {
    if (isset($_GET['table'])) {
        $sql->selectDB(\util\Config::$database->tablesDB);
        $table = $_GET['table'];
        $chart = new \reports\Chart();
        $chart->setType('Table');
        $report = new \reports\Report();
        $report->setTitle($table)->setQuery("SELECT * FROM {$table}")->setChart($chart)->run($sql);
    } else {
        if (isset($_GET['serial'])) {
            $report = \reports\Report::unserialize($_GET['serial']);
            $sql->selectDB(\util\Config::$database->tablesDB);
            $report->run($sql);
        }
    }
}
if (!is_null($report)) {
    $header = new \html\Header();
    $header->title(\util\Config::$app->name)->css('css/style.min.css')->js('js/jquery.min.js', 'js/bootstrap.min.js')->addToIncludes($report->script('chart_container'));
    $content = "<div id='chart_container' class='chart'></div>";
    echo "<!DOCTYPE html>\n<html lang='en'>" . $header->html() . "<body>\n\t\t\t<header>" . \util\Html::genNavbar() . "</header>\n\t\t\t<article>\n\t\t\t\t{$content}\n\t\t\t</article>\n\t\t\t<footer>\n\t\t\t</footer>\n\t\t</body>\n\t</html>";
}
            $vAxis = $_POST['vAxis'];
        }
        $column1 = null;
        if (isset($_POST['column1'])) {
            $column1 = $_POST['column1'];
        }
        $column2 = null;
        if (isset($_POST['column2'])) {
            $column2 = $_POST['column2'];
        }
        $sortcolumn = null;
        if (isset($_POST['sortcolumn'])) {
            $sortcolumn = $_POST['sortcolumn'];
        }
        $type = preg_replace("#[\\s]#", '', $_POST['type']);
        $chart = new \reports\Chart();
        $chart->setTitle($title)->setAxisLabels($vAxis, $hAxis)->setColumnNames(array($column1, $column2))->setType($type);
        $report = new \reports\Report();
        $report->setTitle($title)->setQuery($query)->setChart($chart);
        if (isset($_POST['submit_type']) && $_POST['submit_type'] === 'save_report') {
            \reports\Report::add($report);
            header("Location: run_report.php?report={$title}");
        } else {
            $serial = $report->serialize();
            header("Location: run_report.php?serial={$serial}");
        }
        exit;
    }
}
$header = new \html\Header();
$header->title(\util\Config::$app->name)->css('css/style.min.css')->js('js/jquery.min.js', 'js/bootstrap.min.js');