getReport($_REQUEST['report_id']); if ($_REQUEST['action'] == 'edit') { $_POST['report_name'] = $report->f['report_name']; $_POST['db_name'] = $report->f['db_name']; $_POST['descr'] = $report->f['descr']; $_POST['report_sql'] = $report->f['report_sql']; } // Get a list of available databases $databases = &$data->getDatabases(); echo "

{$lang['strreports']}: ", htmlspecialchars($report->f['report_name']), ": {$lang['stredit']}

\n"; $misc->printMsg($msg); echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
{$lang['strname']}_maxNameLen}\" value=\"", htmlspecialchars($_POST['report_name']), "\" />
{$lang['strdatabase']}
{$lang['strcomment']}
{$lang['strsql']}
\n"; echo "

\n"; echo "\n"; echo "

\n"; echo "f['report_id']}\" />\n"; 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']); 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 $PHP_SELF, $lang; $report = $reportsdb->getReport($_REQUEST['report_id']); echo "

{$lang['strreports']}: ", htmlspecialchars($report->f['report_name']), "

\n"; $misc->printMsg($msg); if ($report->recordCount() == 1) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
{$lang['strname']}", $misc->printVal($report->f['report_name']), "
{$lang['strdatabase']}", $misc->printVal($report->f['db_name']), "
{$lang['strcomment']}", $misc->printVal($report->f['descr']), "
{$lang['strsql']}", $misc->printVal($report->f['report_sql']), "
\n"; } else echo "

{$lang['strinvalidparam']}

\n"; echo "

{$lang['strshowallreports']} |\n"; echo "f['report_id']}\">{$lang['stredit']}

\n"; } /** * Displays a screen where they can enter a new report */ function doCreate($msg = '') { global $data, $reportsdb, $misc; global $PHP_SELF, $lang; if (!isset($_REQUEST['report_name'])) $_REQUEST['report_name'] = ''; if (!isset($_REQUEST['db_name'])) $_REQUEST['db_name'] = ''; if (!isset($_REQUEST['descr'])) $_REQUEST['descr'] = ''; if (!isset($_REQUEST['report_sql'])) $_REQUEST['report_sql'] = ''; $databases = &$data->getDatabases(); echo "

{$lang['strreports']}: {$lang['strcreatereport']}

\n"; $misc->printMsg($msg); echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
{$lang['strname']}_maxNameLen}\" value=\"", htmlspecialchars($_REQUEST['report_name']), "\" />
{$lang['strdatabase']}
{$lang['strcomment']}
{$lang['strsql']}
\n"; echo "

\n"; echo "\n"; echo "

\n"; echo "
\n"; } /** * Actually creates the new report in the database */ function doSaveCreate() { 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'] == '') doCreate($lang['strreportneedsname']); elseif ($_POST['report_sql'] == '') doCreate($lang['strreportneedsdef']); else { $status = $reportsdb->createReport($_POST['report_name'], $_POST['db_name'], $_POST['descr'], $_POST['report_sql']); if ($status == 0) doDefault($lang['strreportcreated']); else doCreate($lang['strreportcreatedbad']); } } /** * Show confirmation of drop and perform actual drop */ function doDrop($confirm) { global $reportsdb, $misc; global $lang; global $PHP_SELF; if ($confirm) { // Fetch report from the database $report = &$reportsdb->getReport($_REQUEST['report_id']); echo "

{$lang['strreports']}: ", $misc->printVal($report->f['report_name']), ": {$lang['strdrop']}

\n"; echo "

", sprintf($lang['strconfdropreport'], $misc->printVal($report->f['report_name'])), "

\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\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 $PHP_SELF, $lang; echo "

{$lang['strreports']}

\n"; $misc->printMsg($msg); $reports = &$reportsdb->getReports(); if ($reports->recordCount() > 0) { echo "\n"; echo "\n"; $i = 0; while (!$reports->EOF) { // @@@@@@@@@ FIX THIS!!!!! $query = urlencode($reports->f['report_sql']); $return_url = urlencode('reports.php'); $return_desc = urlencode($lang['strback']); $id = (($i % 2) == 0 ? '1' : '2'); echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $reports->moveNext(); $i++; } echo "
{$lang['strreport']}{$lang['strdatabase']}{$lang['strcreated']}{$lang['stractions']}
", $misc->printVal($reports->f['report_name']), "", $misc->printVal($reports->f['db_name']), "", $misc->printVal($reports->f['date_created']), "f['db_name']), "&query={$query}&return_url={$return_url}&return_desc={$return_desc}\">{$lang['strrun']}f['report_id'], "\">{$lang['strproperties']}f['report_id'], "\">{$lang['stredit']}f['report_id'], "\">{$lang['strdrop']}
\n"; } else { echo "

{$lang['strnoreports']}

\n"; } echo "

{$lang['strcreatereport']}

\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) { echo "

{$lang['strnoreportsdb']}

\n"; } 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(); ?>