function render($includeHeaders = false) { $xOH = new cHObject(); $cnt = ""; $toMail = count($this->mSenders) >= 1 ? true : false; $body = ""; if ($includeHeaders == true) { $this->mHeader .= getRawHeader(false, $this->mOut); $this->mFooter = getRawFooter(false, $this->mOut) . $this->mFooter; } if ($this->mIncluirH3 == true) { $this->mHeader = $this->mHeader . "<h3 class='title'>" . $this->mTitulo . "</h3>"; } switch ($this->mOut) { case OUT_EXCEL: if ($this->mSQL != "") { $xls = new cHExcel(); $html = $this->mHeader . $this->mBody . $this->mFooter; $xls->addContent($html); //$cnt = $xls->convertTable($this->mSQL, $this->mTitulo, true); $cnt = $xls->render(); } break; case OUT_RXML: $arrPar = array("titulo" => $this->mTitulo); $output = SYS_DEFAULT; $oRpt = new PHPReportMaker(); $oRpt->setParameters($arrPar); $oRpt->setDatabase(MY_DB_IN); $oRpt->setUser(RPT_USR_DB); $oRpt->setPassword(RPT_PWD_DB); $oRpt->setSQL($this->mSQL); $oRpt->setXML("../repository/" . $this->mFile . ".xml"); $oOut = $oRpt->createOutputPlugin("html"); //$oOut->setClean(false); $oRpt->setOutputPlugin($oOut); //echo $oRpt->run(true);exit; if ($toMail == true) { $html = $oRpt->run(true); $title = $xOH->getTitulize($this->mTitulo); $body = $this->mBodyMail == "" ? $title : $this->mBodyMail; $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->set_paper("letter", "portrait"); $dompdf->render(); $this->mFile = PATH_TMP . "" . $title . ".pdf"; $output = $dompdf->output(); file_put_contents($this->mFile, $output); } else { $oRpt->run(); } break; case OUT_PDF: $html = $this->mHeader . $this->mBody . $this->mFooter; $title = $xOH->getTitulize($this->mTitulo); $body = $this->mBodyMail == "" ? $title : $this->mBodyMail; $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->set_paper("letter", "portrait"); $dompdf->render(); if ($toMail == true) { $this->mFile = PATH_TMP . "" . $title . ".pdf"; $output = $dompdf->output(); file_put_contents($this->mFile, $output); } else { $this->mFile = $title . ".pdf"; # Enviamos el fichero PDF al navegador. $dompdf->stream($this->mFile); } break; default: $cnt = $this->mHeader . $this->mBody . $this->mFooter; if ($toMail == true) { $html = $cnt; $title = $xOH->getTitulize($this->mTitulo); $dompdf = new DOMPDF(); $dompdf->load_html($html); $dompdf->set_paper("letter", "portrait"); $dompdf->render(); $body = $this->mBodyMail == "" ? $title : $this->mBodyMail; $this->mFile = PATH_TMP . "" . $title . ".pdf"; $output = $dompdf->output(); file_put_contents($this->mFile, $output); } else { if ($this->mOut == OUT_DOC) { $this->mJS = ""; } $this->mJS = $this->mJS == "" ? "" : "<script>var xRpt = new RepGen();" . $this->mJS . "</script>"; $footerbar = trim($this->mFooterBar) == "" ? "" : "<div class='footer-bar warning'>" . $this->mFooterBar . "</div>"; $cnt = $this->mHeader . $this->mBody . $this->mJS . $footerbar . $this->mFooter; } break; } if ($toMail == true) { $xMail = new cNotificaciones(); foreach ($this->mSenders as $idmail => $email) { $this->mMessages .= $xMail->sendMail($this->mTitulo, $body, $email, array("path" => $this->mFile)); } if ($this->mResponse == true) { $rs = array("message" => $this->mMessages); $cnt = json_encode($rs); } } return $cnt; }