/** * Set user criteria and display report */ function view($VAR) { # validation if (empty($VAR['report_module']) || empty($VAR['report_template'])) { return false; } $module = $VAR['report_module']; $report = $VAR['report_template']; $format = $VAR['report_format']; # include reporting classess require_once PATH_MODULES . 'report/class.Report.php'; require_once PATH_MODULES . 'report/class.Level.php'; require_once PATH_MODULES . 'report/class.ReportParser.php'; set_time_limit(0); if ($format == 'text') { $f = new TXT_ReportFormatter(); } elseif ($format == 'html') { $f = new HTML_ReportFormatter(); } elseif ($format == 'pdf') { $f = new PDF_ReportFormatter(); } # Tell the formatter where to save the output $dir = md5(tempnam(PATH_FILES, "s")); $path = PATH_FILES . 'reports/' . $dir; @unlink($path); mkdir($path, 0775); $f->setOutputDirectory($path); # set report construct file to use $r = new Reporting($f, true); $p = new ReportParser($r); $result = $p->setInputFile(PATH_AGILE . 'reports/' . $module . '/' . $report); # Get user criteria $arr = $p->getUserCriteria(); # Set the user criteria if (!empty($VAR['report']['conditions']) && is_array($VAR['report']['conditions'])) { foreach ($VAR['report']['conditions'] as $arr) { $exp = $arr['exp']; $col = $arr['col']; $val = $arr['value']; $type = $arr['type']; foreach ($col as $i => $name) { if ($type[$i] == 'date_year_month') { $val[$i] = array('month' => $val['month'][$i], 'year' => $val['year'][$i]); } $this->setSQLCondition($p, $col[$i], $exp[$i], $val[$i], $type[$i]); } } } #echo '<pre>'.print_r($p,true).'</pre>'; exit; $result = $p->parse(); #echo '<pre>'.print_r($p,true).'</pre>'; exit; $r->display(); if ($format == 'text') { header('Content-type: text/txt'); header('Content-Disposition: inline; filename="report.txt"'); echo file_get_contents($f->getOutput()); @unlink($f->getOutput()); } elseif ($format == 'html') { $f->getOutput(); $url = URL . 'includes/files/reports/' . $dir . '/report.html'; echo "<script>document.location='{$url}';</script>"; } elseif ($format == 'pdf') { header('Content-type: application/pdf'); header('Content-Disposition: inline; filename="report.pdf"'); readfile($f->getOutput()); @unlink($f->getOutput()); } }