public static function displayNotes() { $header = array("Platform Interface Notes (if available)", "Publisher Notes (if available)"); $dataList = array(ReportNotes::hasPlatforms() ? ReportNotes::platformNotes() : array(), ReportNotes::hasPublishers() ? ReportNotes::publisherNotes() : array()); $n = 2; for ($i = 0; $i < $n; ++$i) { echo "<br/> <br/>"; echo "<table style='border-width: 1px'>\n <tr><td colspan='3'>\n <b>{$header[$i]}</b>\n </td></tr>"; foreach ($dataList[$i] as $data) { echo "<tr valign='top'>\n <td align='right'><b>{$data['reportDisplayName']}</b></td>"; if ($data['startYear'] != '' && ($data['endYear'] == '' || $data['endYear'] == '0')) { echo "<td>Year: {$data['startYear']} to present</td>"; } else { echo "<td>Years: {$data['startYear']} to {$data['endYear']}</td>"; } if ($i) { ReportNotes::printPublisherNote($data); } else { ReportNotes::printPlatformNote($data); } echo "</tr>"; } echo "</table>"; } }
public function __construct($id) { $this->db = new DBService(); $result = $this->db->query("SELECT reportName, reportDatabaseName FROM Report WHERE reportID = '{$id}' LIMIT 1")->fetchRow(MYSQLI_ASSOC); $this->id = $id; $this->name = $result['reportName']; $this->dbname = $result['reportDatabaseName']; ReportNotes::init($this->dbname); if (isset($_REQUEST['titleID']) && $_REQUEST['titleID'] !== null && $_REQUEST['titleID'] !== '') { $this->titleID = $_REQUEST['titleID']; FormInputs::addVisible('titleID', $this->titleID); } if (isset($_REQUEST['sortColumn'])) { $this->sortData['column'] = $_REQUEST['sortColumn']; } if (isset($_REQUEST['sortOrder'])) { $this->sortData['order'] = $_REQUEST['sortOrder']; } FormInputs::addVisible('reportID', $this->id); FormInputs::addHidden('useHidden', 1); FormInputs::addHidden('sortColumn', $this->sortData['column']); FormInputs::addHidden('sortOrder', $this->sortData['order']); Config::init(); if (Config::$settings->baseURL) { if (strpos(Config::$settings->baseURL, '?') > 0) { $this->baseURL = Config::$settings->baseURL . '&'; } else { $this->baseURL = Config::$settings->baseURL . '?'; } } }
public function prepareBody($outputType) { $this->numRows = 0; $tblBody = "<tbody>"; while ($currentRow = $this->reportResult->fetchRowPersist(MYSQLI_ASSOC)) { if (isset($currentRow['platformID'])) { ReportNotes::addPlatform($currentRow['platformID']); } if (isset($currentRow['publisherPlatformID'])) { ReportNotes::addPublisher($currentRow['publisherPlatformID']); } $colnum = 1; $subtotal = 0; $rowOutput = "<tr class='data'>"; foreach (ReportTable::filterRow($currentRow) as $field => $value) { if ($this->performSubtotalFlag && isset($this->columnData['sum'][$field])) { // get the numbers out for summing if ($field === 'QUERY_TOTAL') { $value = $subtotal; } else { $subtotal += $value; } $this->totalSumArray[$field] += $value; } $rowOutput .= $this->formatColumn($outputType, $currentRow, $field, $value); // end if display columns is Y ++$colnum; } // end loop through columns $rowOutput .= "</tr>"; ++$this->numRows; if (!$this->report->onlySummary || $outputType !== 'web') { $tblBody .= $rowOutput; } } $tblBody .= "</tbody>"; return $tblBody; }
} else { $html = array(); for ($i = 1; $i <= 3; $i++) { $html[$i] = array('col' => Color::$levels[$i][2], 'cnt' => $outlier[$i]['count'], '%' => $outlier[$i]['percent']); } $html_top_opt = array("align=right><b>Color Background Key</b>", ">{$nbsp6}", ">{$nbsp6}"); for ($i = 1; $i <= 3; ++$i) { echo "<tr><td colspan='{$rp_fldcnt}'><table style='border: 0px;'><tr><td class='noborder' {$html_top_opt[$i - 1]}</td>\n <td style='width: 20px;' bgcolor='{$html[$i]['col']}'> </td>\n <td class='noborder' colspan='{$modcolcount}'>Programmatically flagged as outlier using the following formula: Count is {$html[$i]['cnt']} over {$html[$i]['%']}% of the previous 12 month average.</td></tr></table></td></tr>"; } echo "<tr><td colspan='{$rp_fldcnt}'><table style='border: 0px;'><tr><td class='noborder'>{$nbsp6}</td>\n <td class='{$outlier_cls[2]}'> </td>\n <td class='noborder' colspan='{$modcolcount}'>{$txt_merged}.</td></tr></table></td></tr>"; } } //////////////////////////legend (end)/////////////////// /* display any publisher or platform notes */ echo "<tr><td class='noborder' style='text-align: left;'>"; ReportNotes::displayNotes(); echo "</td></tr>\n\n </table><br/>\n </td>\n <td class='noborder'> </td>\n </tr>\n </table>\n </center>"; ////////////////////footer////////////////// echo "<script type='text/javascript' src='js/report.js'></script>"; if ($outputType === 'print') { ?> <script type="text/javascript"> <!-- window.print(); //--> </script> <?php } include 'templates/footer.php'; ///////////////////footer (end)/////////////// ob_end_flush();
public function process(DBResult &$reportArray, ReportNotes &$notes) { $countForGrouping = 0; $sumArray = array(); $totalSumArray = array(); $holdArray = array(); $fields = $reportArray->fetchFields(); $numFields = count($fields); if ($numFields !== 0) { echo '<thead>'; $this->processColumns($fields); echo '</thead>'; // loop through resultset $groupArrayCount = count($this->groupColsArray); $rowNum = 1; echo '<tbody>'; while ($currentRow = $reportArray->fetchRowPersist(MYSQLI_ASSOC)) { if (isset($currentRow['platformID'])) { $notes->addPlatform($currentRow['platformID']); } if (isset($currentRow['publisherPlatformID'])) { $notes->addPublisher($currentRow['publisherPlatformID']); } $reset = $rowNum === $this->startPage; $performCheck = false; $print_subtotal_flag = false; $rowoutput = "<tr>"; $colNum = 0; foreach ($currentRow as $field => $data) { // stop displaying columns once we hit title ID or platform ID if ($field === 'titleID' || $field === 'platformID') { break; } if ($data === '') { $data = ' '; } // if sort is explicitly requested we will group on this column if it is allowed according to DB if (isset($holdArray[$colNum]) && isset($this->groupColsArray[$field]) && $data != $holdArray[$colNum]) { if ($this->sortColumn === $colNum + 1) { $hold_rprt_grpng_data = $holdArray[$colNum]; $print_subtotal_flag = true; // if no sort order is specified, use default grouping } else { if ($this->sortOrder === '' && $holdArray[$colNum] != '') { $this->groupColsArray[$field] = true; // default echo flag to Y, we will reset later $print_subtotal_flag = true; $performCheck = true; if ($groupArrayCount === 1) { $hold_rprt_grpng_data = $holdArray[$colNum]; } else { $hold_rprt_grpng_data = 'Group'; } } } } if ($data != (isset($holdArray[$colNum]) ? $holdArray[$colNum] : null) || $reset || $this->outputType === 'xls' || $this->perform_subtotal_flag && $this->sortOrder === '' && $groupArrayCount > 1) { $reset = true; $print_data = $data; } else { if ($print_data == '0' . $print_data) { $print_data = ' '; } else { $print_data = $data; } } if ($this->outputType === 'web' && $print_data !== ' ' && $field === 'TITLE') { if ($this->report->getID() != '1') { $print_data .= '<br><font size="-4"><a target="_BLANK" href="report.php?reportID=1&prm_4=' . ($this->showUnadjusted ? 'Y' : 'N') . "&titleID={$currentRow['titleID']}&outputType=web'>view related titles</a></font>"; } // echo link resolver link if (($currentRow['PRINT_ISSN'] || $currentRow['ONLINE_ISSN']) && isset($this->baseURL)) { $print_data .= '<br><font size="-4"><a target="_BLANK" href="' . $this->getLinkResolverLink($currentRow) . '">view in link resolver</a></font>'; } } if (isset($currentRow[$field . '_OVERRIDE']) || isset($currentRow[$field . '_OUTLIER']) && $currentRow[$field . '_OUTLIER'] > 0) { if (!$this->showUnadjusted && isset($currentRow[$field . '_OVERRIDE'])) { $rowoutput .= "<td class='overriden'>" . $currentRow[$field . '_OVERRIDE'] . "</td>"; } else { if ($this->showUnadjusted) { if ($currentRow[$field . '_OUTLIER'] >= 4) { $tmp_outlier_color = Color::$levelColors[$currentRow[$field . '_OUTLIER'] - 3]; } else { $tmp_outlier_color = Color::$levelColors[$currentRow[$field . '_OUTLIER']]; } $rowoutput .= "<td class='{$tmp_outlier_color['1']}'>{$print_data}</td>"; unset($tmp_outlier_color); } else { $rowoutput .= "<td class='flagged'>{$print_data}</td>"; } } } else { if (isset($currentRow['MERGE_IND'])) { $rowoutput .= "<td class='merged'>{$print_data}</td>"; } else { $rowoutput .= "<td>{$print_data}</td>"; } } $holdArray[$colNum] = $data; if (isset($this->groupColsArray[$field])) { if ($this->sortColumn === $colNum + 1) { $hold_rprt_grpng_data = $holdArray[$colNum]; } else { if ($this->sortOrder === '') { if ($groupArrayCount === 1) { $hold_rprt_grpng_data = $holdArray[$colNum]; } else { $hold_rprt_grpng_data = 'Group'; } } } } // get the numbers out for summing if (isset($sumArray[$field])) { $sumArray[$field][] = $data; $totalSumArray[$field] += $data; // filter_var($data, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) ); } else { $sumArray[$field] = array($data); $totalSumArray[$field] = $data; // filter_var($data, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION) ); } // end if display columns is Y ++$colNum; } // end loop through columns ++$countForGrouping; // loop through the group arrays, if any are N then echo flag is N otherwise it will be left to Y // determine if the current row needs to be grouped if ($this->outputType != 'xls' && !($performCheck && in_array(false, $this->groupColsArray, true) !== false) && $print_subtotal_flag && $this->report->hasGroupTotalInd()) { $rowoutput .= "</tr>"; if ($countForGrouping > 1) { $rowoutput .= "<tr class='data'><td class='sum'>Total for {$hold_rprt_grpng_data}</td>"; foreach ($fields as $field) { $rowoutput .= '<td class="sum">' . $this->sumField($this->sumColsArray[$field], $sumArray[$field]) . '</td>'; } $rowoutput .= '</tr>'; } $sumArray = array(); $countForGrouping = 0; $rowoutput .= "<tr class='data'><td colspan={$numFields}> </td></tr><tr class='data'>"; } ++$rowNum; if ($this->maxRows <= 0 || $rowNum < $this->maxRows) { echo $rowoutput; } if ($rowNum % 15000 === 0) { ob_flush(); } } --$rowNum; if ($this->outputType != 'xls' && $this->perform_subtotal_flag) { if ($this->report->hasGroupTotalInd() && $hold_rprt_grpng_data) { // one last grouping summary if ($countForGrouping > 1) { $grp .= "<tr class='data'><td class='sum'>Total for {$hold_rprt_grpng_data}</td>"; foreach ($fields as $field) { $grp .= "<td class='sum'>" . $this->sumField($this->sumColsArray[$field], $sumArray[$field]) . "</td>"; } echo "{$grp}</tr>"; } echo "<tr class='data'><td colspan={$numFields}> </td></tr>"; } echo '<tr class="data"><td class="sum">Total for Report</td>'; $total = ''; for ($colNum = 1; $colNum < $numFields; ++$colNum) { if (isset($this->sumColsArray[$fields[$colNum]])) { $total = $this->sumColTotal($this->sumColsArray[$fields[$colNum]], $totalSumArray[$fields[$colNum]], $rowNum); } if ($total) { echo "<td class='sum'>{$total}</td>"; } else { echo "<td class='sum'> </td>"; } } echo '</tr>'; } if ($rowNum === 0) { echo "<tr class='data'><td colspan={$numFields}><i>Sorry, no rows were returned."; } else { echo "<tr><td colspan={$numFields} align='right'><i>Showing rows {$this->startPage} to "; if ($this->maxRows > 0 && $rowNum > $this->maxRows) { echo "{$this->maxRows} of {$this->maxRows}"; } else { echo "{$rowNum} of {$rowNum}"; } } echo '</i></td></tr></tbody>'; } }