Пример #1
0
    global $adb;
    global $current_user;
    $theme_path = "themes/" . $theme . "/";
    $image_path = $theme_path . "images/";
    $sGroup = "<GROUP RESET_SUPPRESS_ON_PAGEBREAK='TRUE' REPRINT_HEADER_ON_PAGEBREAK='TRUE'>" . "<HEADER>" . "<ROW><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>签约日期</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>客户</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>合同订单编号</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>订单金额</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>负责人</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>审批人</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>产品名称</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>产品类别</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>型号</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>产品编号</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>数量</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>单位</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>成本价</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>单价</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>售价</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>差价</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>金额</COL><COL CELLCLASS='HEADER' TEXTCLASS='BOLD'>利润</COL></ROW>" . "</HEADER>" . "<FIELDS>" . "<ROW>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>duedate</COL>" . "<COL TYPE='EXPRESSION' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'><LINK TYPE='EXPRESSION' TARGET='blank' TITLE='Click'>\"" . $site_URL . "getCustomerInfo.php?record=\".\$this->getValue('accountid')</LINK>\$this->getValue('accountname')</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>subject</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>total</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>user_name</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>appuser_name</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>productname</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>catalogname</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>serialno</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>productcode</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>quantity</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>usageunit</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>cost_price</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>unit_price</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>listprice</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>profit_price</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD' NUMBERFORMATEX='2'>producttotal</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD' NUMBERFORMATEX='2'>profit</COL>" . "</ROW>" . "</FIELDS>" . "<FOOTER>" . "</FOOTER>" . "</GROUP>";
    $sDoc = "<DOCUMENT>" . "<FOOTER>" . "<ROW>" . "<COL CELLCLASS='FOOTER' TEXTCLASS='BOLD' ALIGN='RIGHT' COLSPAN='14'></COL>" . "<COL CELLCLASS='FOOTER' TEXTCLASS='BOLD' ALIGN='RIGHT'>总金额</COL>" . "<COL TYPE='EXPRESSION' CELLCLASS='FOOTER' TEXTCLASS='BOLD' NUMBERFORMATEX='2'>\$this->getSum('producttotal')</COL>" . "<COL CELLCLASS='FOOTER' TEXTCLASS='BOLD' ALIGN='RIGHT'>总利润</COL>" . "<COL TYPE='EXPRESSION' CELLCLASS='FOOTER' TEXTCLASS='BOLD' NUMBERFORMATEX='2'>\$this->getSum('profit')</COL>" . "</ROW>" . "</FOOTER>" . "</DOCUMENT>";
    echo '<HTML>
            <HEAD>
            <meta http-equiv="Content-Type" content="text/html; charset=utf8">
            <TITLE>销售明细汇总</TITLE>
            <LINK REL="stylesheet" TYPE="text/css" HREF="include/phpreports/sales.css">
            <link href="themes/images/report.css" rel="stylesheet" type="text/css"/></head>';
    echo '<body BGCOLOR="#FFFFFF" marginheight="0" marginwidth="0" leftmargin="0" topmargin="0" style="text-align:center;" align="center">';
    $query = "SELECT ec_account.accountname,ec_account.accountid,ec_salesorder.subject,ec_salesorder.duedate,ec_salesorder.total,ec_users.user_name,ec_salesorder.smownerid,ec_inventoryproductrel.listprice,ec_inventoryproductrel.quantity,ec_inventoryproductrel.listprice*ec_inventoryproductrel.quantity as producttotal,ec_products.productname,ec_products.productcode,ec_products.serialno,ec_products.usageunit,ec_products.unit_price,ec_products.cost_price,(ec_inventoryproductrel.listprice - ec_products.cost_price) AS profit_price,(ec_inventoryproductrel.listprice - ec_products.cost_price)*ec_inventoryproductrel.quantity as profit,ec_users2.user_name as appuser_name,ec_catalog.catalogname FROM ec_salesorder  left join ec_users on ec_users.id=ec_salesorder.smownerid left join ec_account on ec_account.accountid=ec_salesorder.accountid left join ec_inventoryproductrel on ec_inventoryproductrel.id=ec_salesorder.salesorderid left join ec_products on ec_products.productid=ec_inventoryproductrel.productid left join ec_catalog on ec_catalog.catalogid=ec_products.catalogid left join ec_users ec_users2 on ec_users2.id=ec_salesorder.approvedby where ec_salesorder.deleted=0 and ec_salesorder.approved=1 ";
    $query = $listviewreport->addSecurityParameter($query);
    $query = $listviewreport->getModifiedListQuery($query);
    $query .= " ORDER BY ec_salesorder.duedate";
    //    echo $query;
    $oRpt = new PHPReportMaker();
    $oRpt->setDatabaseInterface($dbconfig['db_type']);
    $oRpt->setDatabase($dbconfig['db_name']);
    $oRpt->setUser($dbconfig['db_username']);
    $oRpt->setPassword($dbconfig['db_password']);
    $oRpt->setConnection($dbconfig['db_hostname']);
    $oRpt->setSQL($query);
    $oRpt->setBody(false);
    $oRpt->setPageSize(50000);
    $oRpt->createFromTemplate("销售明细汇总", "include/phpreports/template.xml", null, $sDoc, $sGroup);
    $reportData = $oRpt->run();
    echo '</body></html>';
}
//=====================================================================================================
$fecha_inicial = $_GET["on"];
$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");
include_once "../core/core.fechas.inc.php";
include_once "../libs/sql.inc.php";
include_once "../core/core.config.inc.php";
$fecha_inicial = $_GET["on"];
$fecha_final = $_GET["off"];
$input = $_GET["out"];
if (!$input) {
    $input = "default";
}
include_once "../reports/PHPReportMaker.php";
$sql_set = "SELECT socios_general.codigo, CONCAT(socios_general.nombrecompleto, ' ', socios_general.apellidopaterno, ' ', socios_general.apellidomaterno) AS 'nombre_completo', \r\n\tcaptacion_cuentas.numero_cuenta AS 'numero_de_cuenta',  captacion_cuentas.fecha_apertura AS 'fecha_de_apertura',\r\n\tcaptacion_cuentastipos.descripcion_cuentastipos AS 'tipo_de_cuenta' , captacion_cuentas.saldo_cuenta AS 'saldo_actual', \r\n\tcaptacion_cuentas.inversion_fecha_vcto AS 'proximo_vencimiento', captacion_cuentas.tasa_otorgada, captacion_cuentas.dias_invertidos\r\n\tAS 'numero_de_dias', captacion_cuentas.observacion_cuenta AS 'observaciones', operaciones_mvtos.fecha_afectacion AS 'fecha_de_operacion', \r\n\toperaciones_tipos.descripcion_operacion AS 'tipo_de_operacion', operaciones_mvtos.afectacion_real AS 'monto', operaciones_mvtos.saldo_anterior, \r\n\toperaciones_mvtos.saldo_actual FROM socios_general, captacion_cuentas, operaciones_mvtos, captacion_cuentastipos,  operaciones_tipos \r\n\tWHERE captacion_cuentas.tipo_cuenta=20 and captacion_cuentas.saldo_cuenta>0 and captacion_cuentas.numero_socio=socios_general.codigo \r\n\tAND operaciones_mvtos.docto_afectado=captacion_cuentas.numero_cuenta AND operaciones_mvtos.tipo_operacion=operaciones_tipos.idoperaciones_tipos\r\n\tAND captacion_cuentas.tipo_cuenta=captacion_cuentastipos.idcaptacion_cuentastipos\r\n\tAND operaciones_mvtos.fecha_afectacion>='{$fecha_inicial}' AND operaciones_mvtos.fecha_afectacion<='{$fecha_final}'\r\n\tORDER BY socios_general.codigo,captacion_cuentas.numero_cuenta,  operaciones_mvtos.fecha_afectacion";
//exit($sql_set);
if ($input != OUT_EXCEL) {
    $oRpt = new PHPReportMaker();
    $oRpt->setDatabase(MY_DB_IN);
    $oRpt->setUser(RPT_USR_DB);
    $oRpt->setPassword(RPT_PWD_DB);
    $oRpt->setSQL($sql_set);
    $oRpt->setXML("../repository/report4.xml");
    $oOut = $oRpt->createOutputPlugin($input);
    $oRpt->setOutputPlugin($oOut);
    $oRpt->run();
    //	*/
} else {
    $filename = "export_from_" . date("YmdHi") . "_to_uid-" . $iduser . ".xls";
    header("Content-type: application/x-msdownload");
    header("Content-Disposition: attachment; filename={$filename}");
    header("Pragma: no-cache");
    header("Expires: 0");
    sqltabla($sql_set, "", "fieldnames");
}
Пример #4
0
 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;
 }
 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;
 }
Пример #6
0
<?php

// include the PHPReports classes on the PHP path! configure your path
ini_set("include_path", ini_get("include_path") . ":/var/www/html/medsys/caja/");
include "PHPReportMaker.php";
$sSQL = "select * from almacenes";
$oRpt = new PHPReportMaker();
$oRpt->setXML("sales.xml");
$oRpt->setUser("omorales");
$oRpt->setPassword("wolf3333");
$oRpt->setConnection("localhost");
$oRpt->setDatabaseInterface("mysql");
$oRpt->setSQL($sSQL);
$oRpt->setDatabase("medsys");
$oRpt->run();
?>

Пример #7
0
<?php

require_once "PHPReportMaker.php";
$sParms = "<ROW>" . "<COL ALIGN='RIGHT' CELLCLASS='HEADER'>from</COL>" . "<COL TYPE='EXPRESSION' CELLCLASS='HEADER' TEXTCLASS='BOLD' COLSPAN='4'>\$this->getParameter('from')</COL>" . "</ROW>" . "<ROW>" . "<COL ALIGN='RIGHT' CELLCLASS='HEADER'>till</COL>" . "<COL TYPE='EXPRESSION' CELLCLASS='HEADER' TEXTCLASS='BOLD' COLSPAN='4'>\$this->getParameter('till')</COL>" . "</ROW>";
$sGroup = "<GROUP EXPRESSION='city'>" . "<HEADER>" . "<ROW><COL CELLCLASS='HEADER' TEXTCLASS='BOLD' TYPE='EXPRESSION' COLSPAN='50'>\$this->getValue('city')</COL></ROW>" . "</HEADER>" . "<FIELDS>" . "<ROW>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD' SUPPRESS='TRUE'>name</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>type</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD'>item</COL>" . "<COL TYPE='FIELD' CELLCLASSEVEN='EVEN' CELLCLASSODD='ODD' NUMBERFORMATEX='2' ALIGN='RIGHT'>value</COL>" . "</ROW>" . "</FIELDS>" . "<FOOTER>" . "<ROW>" . "<COL CELLCLASS='FOOTER' ALIGN='RIGHT' COLSPAN='3'>total</COL>" . "<COL TYPE='EXPRESSION' CELLCLASS='FOOTER' TEXTCLASS='BOLD' NUMBERFORMATEX='2'>\$this->getSum('value')</COL>" . "</ROW>" . "</FOOTER>" . "</GROUP>";
$sDoc = "<DOCUMENT>" . "<FOOTER>" . "<ROW>" . "<COL CELLCLASS='FOOTER' TEXTCLASS='BOLD' ALIGN='RIGHT' COLSPAN='3'>GRAND TOTAL</COL>" . "<COL TYPE='EXPRESSION' CELLCLASS='FOOTER' TEXTCLASS='BOLD' NUMBERFORMATEX='2'>\$this->getSum('value')</COL>" . "</ROW>" . "</FOOTER>" . "</DOCUMENT>";
$oRpt = new PHPReportMaker();
$oRpt->setUser("taq");
$oRpt->setPassword("******");
$oRpt->setSQL("select * from sales order by city,name");
$oRpt->setDatabaseInterface("mysql");
$oRpt->setDatabase("phpreports");
$oRpt->setParameters(array("from" => "today", "till" => "tomorrow"));
$oRpt->createFromTemplate("Template report", "template.xml", $sParms, $sDoc, $sGroup);
$oRpt->run();