Skip to content

Commit

Permalink
Update GetRptLinks function
Browse files Browse the repository at this point in the history
Update retrieve handling for forms and reports.

See:
http://www.weberp.org/forum/showthread.php?tid=7996&pid=15926#pid15926
  • Loading branch information
TurboPT committed Jan 19, 2020
1 parent e3b6938 commit afbbb76
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions index.php
Expand Up @@ -186,7 +186,7 @@ function GetRptLinks($GroupID) {
$GroupID = $ReportList[$GroupID];
$Title = array(_('Custom Reports'), _('Standard Reports and Forms'));

if (!isset($_SESSION['ReportList'])) {
if (empty($_SESSION['ReportList'])) {
$SQL = "SELECT id,
reporttype,
defaultreport,
Expand All @@ -196,44 +196,48 @@ function GetRptLinks($GroupID) {
ORDER BY groupname,
reportname";
$Result = DB_query($SQL, '', '', false, true);

$_SESSION['ReportList'] = array();
while ($Temp = DB_fetch_array($Result)) {

while ($Temp = DB_fetch_assoc($Result)) {
$_SESSION['ReportList'][] = $Temp;
}
}

$RptLinks = '';
for ($Def = 1;$Def >= 0;$Def--) {
for ($Def = 1; $Def >= 0; $Def--) {
$RptLinks.= '<li class="menu_group_headers">';
$RptLinks.= '<b>' . $Title[$Def] . '</b>';
$RptLinks.= '</li>';
$NoEntries = true;
if (isset($_SESSION['ReportList']['groupname']) and count($_SESSION['ReportList']['groupname']) > 0) { // then there are reports to show, show by grouping

if (!empty($_SESSION['ReportList'])) { // then there are reports to show, show by grouping
foreach ($_SESSION['ReportList'] as $Report) {
if (isset($Report['groupname']) and $Report['groupname'] == $GroupID and $Report['defaultreport'] == $Def) {
$RptLinks.= '<li class="menu_group_item">';
$RptLinks.= '<p><a href="' . $RootPath . '/reportwriter/ReportMaker.php?action=go&amp;reportid=' . urlencode($Report['id']) . '">&bull; ' . _($Report['reportname']) . '</a></p>';
$RptLinks.= '</li>';
$RptLinks .= '<li class="menu_group_item">';
$RptLinks .= '<p><a href="' . $RootPath . '/reportwriter/ReportMaker.php?action=go&amp;reportid=';
$RptLinks .= urlencode($Report['id']) . '">&nbsp; ' . _($Report['reportname']) . '</a></p>';
$RptLinks .= '</li>';
$NoEntries = false;
}
}

// now fetch the form groups that are a part of this group (List after reports)
$NoForms = true;
foreach ($_SESSION['ReportList'] as $Report) {
$Group = explode(':', $Report['groupname']); // break into main group and form group array
if ($NoForms and $Group[0] == $GroupID and $Report['reporttype'] == 'frm' and $Report['defaultreport'] == $Def) {
$RptLinks.= '<li class="menu_group_item">';
$RptLinks.= '<img src="' . $RootPath . '/css/' . $_SESSION['Theme'] . '/images/folders.gif" width="16" height="13" alt="" />&nbsp;';
$RptLinks.= '<a href="' . $RootPath . '/reportwriter/FormMaker.php?id=' . urlencode($Report['groupname']) . '">&bull; ';
$RptLinks.= $_SESSION['FormGroups'][$Report['groupname']] . '</a>';
$RptLinks.= '</li>';
$RptLinks .= '<li class="menu_group_item">';
$RptLinks .= '<img src="' . $RootPath . '/css/' . $_SESSION['Theme'] . '/images/folders.gif" width="16" height="13" alt="" />&nbsp; ';
$RptLinks .= '<p><a href="' . $RootPath . '/reportwriter/FormMaker.php?id=' . urlencode($Report['groupname']) . '">';
$RptLinks .= $_SESSION['FormGroups'][$Report['groupname']] . '</a></p>';
$RptLinks .= '</li>';
$NoForms = false;
$NoEntries = false;
}
}
}
if ($NoEntries) $RptLinks.= '<li class="menu_group_item">' . _('There are no reports to show!') . '</li>';
if ($NoEntries) $RptLinks .= '<li class="menu_group_item">&nbsp; ' . _('There are no reports to show!') . '</li>';
}
return $RptLinks;
}

?>

0 comments on commit afbbb76

Please sign in to comment.