$fecha_final = $_GET["off"]; $compFecha = "\n\t\t(`seguimiento_compromisos`.`fecha_vencimiento` >= '{$fecha_inicial}')\n\t\tAND\n\t\t(`seguimiento_compromisos`.`fecha_vencimiento` <= '{$fecha_final}')"; $input = $_GET["out"]; if (!$input) { $input = "default"; } $setSql = " SELECT\n\t`oficiales`.`id` AS 'oficial',\n\t`oficiales`.`nombre_completo`,\n\t`oficiales`.`puesto`,\n\t`oficiales`.`sucursal`,\n\n\n\t`seguimiento_compromisos`.`socio_comprometido`,\n\t`socios`.`nombre`,\n\n\t`seguimiento_compromisos`.`credito_comprometido`,\n\t`seguimiento_compromisos`.`idseguimiento_compromisos` AS 'clave',\n\t`seguimiento_compromisos`.`fecha_vencimiento`,\n\t`seguimiento_compromisos`.`hora_vencimiento`,\n\t`seguimiento_compromisos`.`tipo_compromiso`,\n\t`seguimiento_compromisos`.`anotacion`,\n\t`seguimiento_compromisos`.`estatus_compromiso`\n\nFROM\n\t`seguimiento_compromisos` `seguimiento_compromisos`\n\t\tINNER JOIN `socios` `socios`\n\t\tON `seguimiento_compromisos`.`socio_comprometido` = `socios`.`codigo`\n\t\t\tINNER JOIN `oficiales` `oficiales`\n\t\t\tON `seguimiento_compromisos`.`oficial_de_seguimiento` = `oficiales`.\n\t\t\t`id`\nWHERE\n\t{$compFecha}\nORDER BY\n\t`oficiales`.`id`,\n\t`seguimiento_compromisos`.`fecha_vencimiento`,\n\t`seguimiento_compromisos`.`hora_vencimiento`,\n\t`seguimiento_compromisos`.`tipo_compromiso`"; //exit($setSql); if ($input != OUT_EXCEL) { $oRpt = new PHPReportMaker(); $oRpt->setDatabase(MY_DB_IN); $oRpt->setUser(RPT_USR_DB); $oRpt->setPassword(RPT_PWD_DB); $oRpt->setSQL($setSql); $oRpt->setXML("../repository/report72.xml"); $oOut = $oRpt->createOutputPlugin($input); $oRpt->setOutputPlugin($oOut); $oRpt->run(); // */ } else { $filename = $_SERVER['SCRIPT_NAME']; $filename = str_replace(".php", "", $filename); $filename = str_replace("rpt", "", $filename); $filename = str_replace("-", "", $filename); $filename = "{$filename}-" . date("YmdHi") . "-from-" . $iduser . ".xls"; header("Content-type: application/x-msdownload"); header("Content-Disposition: attachment; filename={$filename}"); header("Pragma: no-cache"); header("Expires: 0"); $cTbl = new cTabla($setSql); $cTbl->setWidth();
protected function btnGenerate_Click() { $this->blnGenerate = true; // Expand the Asset object to include the AssetModel, Category, Manufacturer, and Location Objects $objExpansionMap[AssetTransaction::ExpandAsset][Asset::ExpandAssetModel][AssetModel::ExpandCategory] = true; $objExpansionMap[AssetTransaction::ExpandAsset][Asset::ExpandAssetModel][AssetModel::ExpandManufacturer] = true; $objExpansionMap[AssetTransaction::ExpandSourceLocation] = true; $objExpansionMap[AssetTransaction::ExpandDestinationLocation] = true; $objExpansionMap[AssetTransaction::ExpandTransaction][Transaction::ExpandTransactionType] = true; $objExpansionMap[AssetTransaction::ExpandTransaction][Transaction::ExpandCreatedByObject] = true; $objExpansionMap[AssetTransaction::ExpandTransaction][Transaction::ExpandModifiedByObject] = true; $arrTransactionTypes = array(); // Create an array of checked transaction types if ($this->chkMove->Checked) { $arrTransactionTypes[] = 1; } if ($this->chkCheckIn->Checked) { $arrTransactionTypes[] = 2; } if ($this->chkCheckOut->Checked) { $arrTransactionTypes[] = 3; } if ($this->chkReserve->Checked) { $arrTransactionTypes[] = 8; } if ($this->chkUnreserve->Checked) { $arrTransactionTypes[] = 9; } // Archived assets will be included in the Asset Transaction Report //$arrTransactionTypes[] = 10; // If checked at least one transaction type if (count($arrTransactionTypes)) { $this->lblReport->Warning = ""; // Total Transactions Count $intTotalTransactionCount = AssetTransaction::CountTransactionsBySearch($this->txtShortDescription->Text, $this->txtAssetCode->Text, $this->txtAssetModelCode->Text, $this->lstUser->SelectedValue, $this->lstCheckedOutBy->SelectedValue, $this->lstReservedBy->SelectedValue, $this->lstCategory->SelectedValue, $this->lstManufacturer->SelectedValue, $this->lstTransactionDate->SelectedValue, $this->dtpTransactionDateFirst->DateTime, $this->dtpTransactionDateLast->DateTime, $arrTransactionTypes, $objExpansionMap); // Total Transactions Count > 0 to avoid bug with NoDataMsg if ($intTotalTransactionCount) { // begins the report process $oRpt = new PHPReportMaker(); // Create the constant to use in xml template $oRpt->putEnvObj("TotalTransactions", $intTotalTransactionCount); //some data to show in the report $sSql = AssetTransaction::LoadArrayBySearch(true, $this->txtShortDescription->Text, $this->txtAssetCode->Text, $this->txtAssetModelCode->Text, $this->lstUser->SelectedValue, $this->lstCheckedOutBy->SelectedValue, $this->lstReservedBy->SelectedValue, $this->lstCategory->SelectedValue, $this->lstManufacturer->SelectedValue, $this->lstSortByDate->SelectedValue, $this->lstTransactionDate->SelectedValue, $this->dtpTransactionDateFirst->DateTime, $this->dtpTransactionDateLast->DateTime, $arrTransactionTypes, $objExpansionMap); $strXmlColNameByCustomField = ""; $strXmlFieldByCustomField = ""; $intCustomFieldCount = 0; if ($this->chkCustomFieldArray) { foreach ($this->chkCustomFieldArray as $chkCustomField) { if ($chkCustomField->Checked) { $strXmlColNameByCustomField .= "<COL CELLCLASS='report_column_header'>" . $chkCustomField->Text . "</COL>"; $strXmlFieldByCustomField .= "<COL TYPE='FIELD' CELLCLASS='report_cell'>__" . $chkCustomField->ActionParameter . "</COL>"; $intCustomFieldCount++; } } } $oGroups = "\n <GROUP NAME='transaction_id' EXPRESSION='transaction_id' PAGEBREAK='FALSE'>\n <HEADER>\n <ROW>\n <COL ALIGN='LEFT' TYPE='EXPRESSION' COLSPAN='" . (4 + $intCustomFieldCount) . "' CELLCLASS='report_section_heading'>\$this->getValue('asset_transaction__transaction_id__transaction_type_id__short_description').' by '.(\$this->getValue('asset_transaction__transaction_id__modified_by')?\$this->getValue('asset_transaction__transaction_id__modified_by__first_name').' '.\$this->getValue('asset_transaction__transaction_id__modified_by__last_name').' on '.\$this->getValue('asset_transaction__transaction_id__modified_date'):\$this->getValue('asset_transaction__transaction_id__created_by__first_name').' '.\$this->getValue('asset_transaction__transaction_id__created_by__last_name').' on '.\$this->getValue('asset_transaction__transaction_id__creation_date'))</COL>\n </ROW>\n\t\t\t\t<ROW>\n <COL ALIGN='LEFT' TYPE='EXPRESSION' COLSPAN='" . (4 + $intCustomFieldCount) . "' CELLCLASS='report_cell'>\$this->getValue('asset_transaction__transaction_id__note')</COL>\n </ROW>\n <ROW>\n <COL CELLCLASS='report_column_header'>Asset Code:</COL>\n <COL CELLCLASS='report_column_header'>Asset Model:</COL>\n <COL CELLCLASS='report_column_header'>From:</COL>\n <COL CELLCLASS='report_column_header'>To:</COL>\n {$strXmlColNameByCustomField}\n </ROW>\n </HEADER>\n <FIELDS>\n <ROW>\n <COL TYPE='FIELD' CELLCLASS='report_cell'><LINK TYPE='EXPRESSION'>'" . __SUBDIRECTORY__ . "/assets/asset_edit.php?intAssetId='.\$this->getValue('asset_transaction__asset_id__asset_id')</LINK>asset_transaction__asset_id__asset_code</COL>\n <COL TYPE='FIELD' CELLCLASS='report_cell'><LINK TYPE='EXPRESSION'>'" . __SUBDIRECTORY__ . "/assets/asset_model_edit.php?intAssetModelId='.\$this->getValue('asset_transaction__asset_id__asset_model_id__asset_model_id')</LINK>asset_transaction__asset_id__asset_model_id__short_description</COL>\n <COL TYPE='FIELD' CELLCLASS='report_cell'>asset_transaction__source_location_id__short_description</COL>\n <COL TYPE='FIELD' CELLCLASS='report_cell'>asset_transaction__destination_location_id__short_description</COL>\n {$strXmlFieldByCustomField}\n </ROW>\n </FIELDS>\n </GROUP>"; $arrDBInfo = unserialize(DB_CONNECTION_1); $oRpt->setSQL($sSql); $oRpt->setUser($arrDBInfo['username']); $oRpt->setPassword($arrDBInfo['password']); $oRpt->setConnection($arrDBInfo['server']); $oRpt->setDatabaseInterface('mysql'); $oRpt->setDatabase($arrDBInfo['database']); $oRpt->setNoDataMsg("No data was found, check your query"); $oRpt->setPageSize(200000000); if ($this->lstGenerateOptions->SelectedValue == "print") { // Start the output buffer ob_start(); $this->lblReport->Text = ""; $oDocs = "<CSS>../css/tracmor.css</CSS>"; $fOut = fopen(".." . __TRACMOR_TMP__ . "/" . $_SESSION['intUserAccountId'] . "_asset_transaction_report.htm", "w"); $oRpt->createFromTemplate('Asset Transaction Report', __DOCROOT__ . __SUBDIRECTORY__ . '/reports/asset_transaction_report.xml', null, $oDocs, $oGroups); $oRpt->run(); fwrite($fOut, ob_get_contents()); ob_end_clean(); fclose($fOut); // Open generated Report in new window QApplication::ExecuteJavaScript("window.open('.." . __TRACMOR_TMP__ . "/" . $_SESSION['intUserAccountId'] . "_asset_transaction_report.htm','AssetTransactionReport','resizeable=yes,menubar=yes,scrollbars=yes,left=0,top=0,width=800,height=600');history.go(-1);"); exit; } else { if ($this->lstGenerateOptions->SelectedValue == "csv") { $this->RenderCsvBegin(false); session_cache_limiter('must-revalidate'); // force a "no cache" effect header("Pragma: hack"); // IE chokes on "no cache", so set to something, anything, else. $ExpStr = "Expires: " . gmdate("D, d M Y H:i:s", time()) . " GMT"; header($ExpStr); header('Content-Type: text/csv'); header('Content-Disposition: csv; filename=export.csv'); ob_end_clean(); $oRpt->createFromTemplate('Asset Transaction Report', __DOCROOT__ . __SUBDIRECTORY__ . '/reports/asset_transaction_report.xml', null, null, $oGroups); $oOut = $oRpt->createOutputPlugin("csv"); $oRpt->setOutputPlugin($oOut); $oRpt->run(); ob_get_contents(); @ob_flush(); flush(); $this->RenderCsvEnd(false); exit; } else { // Start the output buffer ob_start(); // The head of the final html will be write by the Qform $oRpt->setBody(false); $oRpt->createFromTemplate('Asset Transaction Report', __DOCROOT__ . __SUBDIRECTORY__ . '/reports/asset_transaction_report.xml', null, null, $oGroups); $oRpt->run(); // Put the output buffer content in the Qlabel $this->lblReport->Text = ob_get_contents(); // Clean the output buffer ob_end_clean(); } } // Begin rendering the QForm //$this->RenderBegin(false); //ob_end_clean(); // Process the report //$oOut = $oRpt->createOutputPlugin("csv"); //$oRpt->setOutputPlugin($oOut); //$this->RenderEnd(false); //exit(); } else { $this->lblReport->Text = ""; $this->lblReport->Warning = "No data was found, check your query."; } } else { $this->lblReport->Text = ""; $this->lblReport->Warning = "You must check at least one transaction type."; } $this->blnGenerate = false; }
<?php require_once "PHPReportMaker.php"; /****************************************************************************** * * * Use this file to see a sample of PHPReports. * * Please check the PDF manual for see how to use it. * * It need to be placed on a directory reached by the web server. * * * ******************************************************************************/ $oRpt = new PHPReportMaker(); $oRpt->setUser("taq"); $oRpt->setPassword("******"); $oRpt->setXML("sales.xml"); $oOut = $oRpt->createOutputPlugin("default"); $oRpt->setOutputPlugin($oOut); $oRpt->run();
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; }