public static function genTableList() { $sql = new \sql\Database(); $sql->selectDB(\util\Config::$database->tablesDB); $table_names = $sql->tableNames(); $list = ""; foreach ($table_names as $tname) { $list .= "<li><a href=\"run_report.php?table=" . $tname . "\">" . $tname . "</a></li>"; } return $list; }
public static function convertToSql($input_filepath, $dbname) { $objPHPExcel = self::loadFile($input_filepath); $tables = array(); foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) { $tbl = new \excel2sql\SqlTable($worksheet, $input_filepath); if ($tbl->finalize()) { $tables[$tbl->name] = $tbl->finalize(); } else { error_log("table import failed: {$input_filepath}/{$tbl->name}"); } } $sql = new \sql\Database(); $sql->selectDB($dbname); $table_names = array(); foreach ($tables as $tname => $queries) { $sql->query($queries["drop"]); $sql->query($queries["creation"]); $sql->query($queries["insertion"]); $table_names[] = $tname; } return $table_names; }
<?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>"; }
public static function update($report) { $sql = new \sql\Database(); $sql->selectDB(\util\Config::$database->reportsDB); $sql->query("UPDATE reports SET serial='" . $report->serialize() . "'" . "WHERE title='" . $report->title() . "'"); }