getReport($_REQUEST['report_id']); if ($_REQUEST['action'] == 'edit') { $_POST['report_name'] = $report->fields['report_name']; $_POST['db_name'] = $report->fields['db_name']; $_POST['descr'] = $report->fields['descr']; $_POST['report_sql'] = $report->fields['report_sql']; if ($report->fields['paginate'] == 't') { $_POST['paginate'] = TRUE; } } // Get a list of available databases $databases = $data->getDatabases(); $_REQUEST['report'] = $report->fields['report_name']; $misc->printTrail('report'); $misc->printTitle($lang['stredit']); $misc->printMsg($msg); echo "
\n"; } /** * Saves changes to a report */ function doSaveEdit() { global $reportsdb, $lang; if (!isset($_POST['report_name'])) $_POST['report_name'] = ''; if (!isset($_POST['db_name'])) $_POST['db_name'] = ''; if (!isset($_POST['descr'])) $_POST['descr'] = ''; if (!isset($_POST['report_sql'])) $_POST['report_sql'] = ''; // Check that they've given a name and a definition if ($_POST['report_name'] == '') doEdit($lang['strreportneedsname']); elseif ($_POST['report_sql'] == '') doEdit($lang['strreportneedsdef']); else { $status = $reportsdb->alterReport($_POST['report_id'], $_POST['report_name'], $_POST['db_name'], $_POST['descr'], $_POST['report_sql'], isset($_POST['paginate'])); if ($status == 0) doDefault($lang['strreportcreated']); else doEdit($lang['strreportcreatedbad']); } } /** * Display read-only properties of a report */ function doProperties($msg = '') { global $data, $reportsdb, $misc; global $lang; $report = $reportsdb->getReport($_REQUEST['report_id']); $_REQUEST['report'] = $report->fields['report_name']; $misc->printTrail('report'); $misc->printTitle($lang['strproperties']); $misc->printMsg($msg); if ($report->recordCount() == 1) { echo "{$lang['strname']} | \n"; echo "", $misc->printVal($report->fields['report_name']), " |
---|---|
{$lang['strdatabase']} | \n"; echo "", $misc->printVal($report->fields['db_name']), " |
{$lang['strcomment']} | \n"; echo "", $misc->printVal($report->fields['descr']), " |
{$lang['strsql']} | \n"; echo "", $misc->printVal($report->fields['report_sql']), " |
{$lang['strinvalidparam']}
\n"; echo "", sprintf($lang['strconfdropreport'], $misc->printVal($report->fields['report_name'])), "
\n"; echo "\n"; } else { $status = $reportsdb->dropReport($_POST['report_id']); if ($status == 0) doDefault($lang['strreportdropped']); else doDefault($lang['strreportdroppedbad']); } } /** * Show default list of reports in the database */ function doDefault($msg = '') { global $data, $misc, $reportsdb; global $lang; $misc->printTrail('server'); $misc->printTabs('server','reports'); $misc->printMsg($msg); $reports = $reportsdb->getReports(); $columns = array( 'report' => array( 'title' => $lang['strreport'], 'field' => field('report_name'), 'url' => "reports.php?action=properties&{$misc->href}&", 'vars' => array('report_id' => 'report_id'), ), 'database' => array( 'title' => $lang['strdatabase'], 'field' => field('db_name'), ), 'created' => array( 'title' => $lang['strcreated'], 'field' => field('date_created'), ), 'actions' => array( 'title' => $lang['stractions'], ), 'comment' => array( 'title' => $lang['strcomment'], 'field' => field('descr'), ), ); $return_url = urlencode("reports.php?{$misc->href}"); $actions = array( 'run' => array( 'title' => $lang['strexecute'], 'url' => "sql.php?subject=report&{$misc->href}&return_url={$return_url}&return_desc=".urlencode($lang['strback'])."&", 'vars' => array('report' => 'report_name', 'database' => 'db_name', 'reportid' => 'report_id', 'paginate' => 'paginate'), ), 'edit' => array( 'title' => $lang['stredit'], 'url' => "reports.php?action=edit&{$misc->href}&", 'vars' => array('report_id' => 'report_id'), ), 'drop' => array( 'title' => $lang['strdrop'], 'url' => "reports.php?action=confirm_drop&{$misc->href}&", 'vars' => array('report_id' => 'report_id'), ), ); $misc->printTable($reports, $columns, $actions, $lang['strnoreports']); echo "\n"; } $misc->printHeader($lang['strreports']); $misc->printBody(); // Create a database accessor for the reports database include_once('./classes/Reports.php'); $reportsdb = new Reports($status); if ($status != 0) { $misc->printTrail('server'); $misc->printTabs('server','reports'); $misc->printMsg($lang['strnoreportsdb']); } else { switch ($action) { case 'save_edit': if (isset($_POST['cancel'])) doDefault(); else doSaveEdit(); break; case 'edit': doEdit(); break; case 'properties': doProperties(); break; case 'save_create': if (isset($_POST['cancel'])) doDefault(); else doSaveCreate(); break; case 'create': doCreate(); break; case 'drop': if (isset($_POST['drop'])) doDrop(false); else doDefault(); break; case 'confirm_drop': doDrop(true); break; default: doDefault(); break; } } $misc->printFooter(); ?>