Ejemplo n.º 1
0
 public static function genReportList()
 {
     $reports = \reports\Report::getList();
     $list = '';
     for ($i = 0; $i < count($reports); ++$i) {
         $list .= "<li><a href=\"run_report.php?report=" . $reports[$i][0] . "\">" . $reports[$i][0] . "</a></li>";
     }
     return $list;
 }
Ejemplo n.º 2
0
 public static function get($title)
 {
     $sql = new \sql\Database();
     $sql->selectDB(\util\Config::$database->reportsDB);
     $table_names = $sql->tableNames();
     if (empty($table_names)) {
         die("Invalid Report request.");
     }
     $table = $table_names[0];
     $result = $sql->query("SELECT serial FROM {$table} WHERE title='{$title}'");
     return \reports\Report::unserialize($result->records()[0][0]);
 }
Ejemplo n.º 3
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>";
}
        }
        $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');
$form = new \html\FormPanel("Import Spreadsheets", "form-panel", 'md-10', "form-horizontal", "");
foreach ($errors as $err) {
    $form->error($err);
}
echo "<header>" . \util\Html::genNavbar() . "</header>";