function MakeReport($parameters, $ACTIVITY)
{
    $theReport = new reportDisplay($parameters, $ACTIVITY);
    $theReport->pageLength = $ACTIVITY->sat_report_page_length;
    $theReport->setPageLength($ACTIVITY->sat_report_page_length);
    $theReport->buildReport();
    print $theReport->styleSheet;
    $pageNo = 1;
    //-first page start div
    $theReport->section[0]->html = "\n<!-- start of page -->\n<div style='height:{$theReport->pageLength}'>\n" . $theReport->section[0]->html;
    //-last page end div
    $theReport->section[count($theReport->section) - 1]->html = $theReport->section[count($theReport->section) - 1]->html . "</div>\n<!-- end of page -->\n\n";
    //--end page div
    for ($i = 0; $i < count($theReport->section); $i++) {
        $theReport->section[$i]->html = str_replace('#thePageNumber#', $pageNo, $theReport->section[$i]->html);
        if ($theReport->section[$i]->isFooter) {
            $pageNo = $pageNo + 1;
        }
    }
    if ($pageNo != 1) {
        $pageNo = $pageNo - 1;
    }
    for ($i = 0; $i < count($theReport->section); $i++) {
        $theReport->section[$i]->html = str_replace('#totalNumberOfPages#', $pageNo, $theReport->section[$i]->html);
    }
    for ($i = 0; $i < count($theReport->section); $i++) {
        print $theReport->section[$i]->html;
    }
    print "\n</body></html>";
    for ($i = 0; $i < count($theReport->tablesUsed); $i++) {
        nuRunQuery("DROP TABLE " . $theReport->tablesUsed[$i]);
    }
}
function MakeReport($parameters, $ACTIVITY)
{
    //tofile("Count Total Pages: ".$GLOBALS['TotalPages']);
    $GLOBALS['CountTotalPages'] = 0;
    $GLOBALS['TotalPages'] = 0;
    $theReport = new reportDisplay($parameters, $ACTIVITY);
    $theReport->SetMargins(1, 1);
    $theReport->pageLength = $ACTIVITY->sat_report_page_length;
    $theReport->setPageLength($ACTIVITY->sat_report_page_length);
    $theReport->buildReport();
    //tofile("Total Pages: ".$GLOBALS['TotalPages']);
    $GLOBALS['CountTotalPages'] = 1;
    //tofile("Count Total Pages ".$GLOBALS['CountTotalPages']);
    $theReport = new reportDisplay($parameters, $ACTIVITY);
    $theReport->SetMargins(1, 1);
    $theReport->pageLength = $ACTIVITY->sat_report_page_length;
    $theReport->setPageLength($ACTIVITY->sat_report_page_length);
    $theReport->buildReport();
    //print $theReport->styleSheet;
    $pageNo = 1;
    //-first page start div
    $theReport->section[0]->html = "\n<!-- start of page -->\n<div style='height:{$theReport->pageLength}'>\n" . $theReport->section[0]->html;
    //-last page end div
    $theReport->section[count($theReport->section) - 1]->html = $theReport->section[count($theReport->section) - 1]->html . "</div>\n<!-- end of page -->\n\n";
    //--end page div
    for ($i = 0; $i < count($theReport->section); $i++) {
        $theReport->section[$i]->html = str_replace('#thePageNumber#', $pageNo, $theReport->section[$i]->html);
        if ($theReport->section[$i]->isFooter) {
            $pageNo = $pageNo + 1;
        }
    }
    $pageNo = $pageNo - 1;
    for ($i = 0; $i < count($theReport->section); $i++) {
        $theReport->section[$i]->html = str_replace('#totalNumberOfPages#', $pageNo, $theReport->section[$i]->html);
    }
    for ($i = 0; $i < count($theReport->section); $i++) {
        //print $theReport->section[$i]->html;
    }
    //print "\n</body></html>";
    for ($i = 0; $i < count($theReport->tablesUsed); $i++) {
        nuRunQuery("DROP TABLE " . $theReport->tablesUsed[$i]);
    }
    $theReport->SetDisplayMode(100);
    $theReport->Output();
    tofile('goot here3');
}