function connect() { //db username and password $host = 'localhost:3306'; $dbname = 'zakila'; $username = '******'; $password = ''; $report = $this->compileReporte(); $fillManager = new \JavaClass("net.sf.jasperreports.engine.JasperFillManager"); $params = new \Java("java.util.HashMap"); $params->put("REPORT_LOCALE", $this->convertValue("en_US", "java.util.Locale")); if (!empty($this->parametros)) { foreach ($this->parametros as $key => $value) { $params->put($key, $value); } } $class = new \JavaClass("java.lang.Class"); $class->forName("com.mysql.jdbc.Driver"); $driverManager = new \JavaClass("java.sql.DriverManager"); try { $conn = $driverManager->getConnection("jdbc:mysql://{$host}/{$dbname}?zeroDateTimeBehavior=convertToNull", $username, $password); $jasperPrint = $fillManager->fillReport($report, $params, $conn); } catch (\JavaException $ex) { echo $ex->getCause(); } $this->jasperPrint = $jasperPrint; }
/** * Allocate a thread and an associated PHP continuation * * @arg nr The data will be passed to the PHP run method * @arg name The current script name * @return the PHP continuation. */ function createRunnable($nr, $name) { global $IRunnable; $r = new Java("php.java.script.InvocablePhpScriptEngine"); $r->put("name", $name); $r->eval(new Java("java.io.FileReader", $name)); $r->put("nr", $nr); $r->put("thread", new java("java.lang.Thread", $r->getInterface($IRunnable))); return $r; }
$queryTime = 0; $bandHelper = new DiscreteBandHelper(DiscreteBandHelper::LABEL_TYPE_BAND, $bandScheme); $ozoneBand = $bandHelper->getBand(); $bandHashMap = new Java("java.util.HashMap"); foreach ($ozoneBand as $key => $val) { $bandHashMap->put($key, doubleval($val)); } //print "# debug: gridExtent: "; //print_r ($gridExtent); //print "\n"; //$driver = new Java('LatLongInterpolation.LatLngDriver', $bandHashMap); // use grid configuration in $gridExtent //$driver = new Java('LatLongInterpolation.LatLngDriver', $bandHashMap, $gridExtent); $gridExtentMap = new Java("java.util.HashMap"); foreach ($gridExtent as $key => $val) { $gridExtentMap->put($key, doubleval($val)); } $driverStart = microtime(true); $driver = new Java('LatLongInterpolation_testing.LatLngDriver', $bandHashMap, $gridExtentMap); $driver->setWriteDebugImages(false); $driverTime = microtime(true) - $driverStart; $queryTime = 0; $gridTime = 0; $contourTime = 0; // query based on timestamp $readOnly = false; // disable gzip -- TMH 2012/07/13 $useGzip = false; // pad with JSONP -- TMH 2012/07/20 $useJSONP = true; // keep history -- TMH 2012/08/31
function callReport($nomReport, $arrParam) { global $SYS; require_once "Java.inc"; //java_require(dirname(__FILE__)."/jfreechart-1.0.1.jar"); java_require(dirname(__FILE__) . "/drivers.jar"); //java_require("/usr/share/java/postgresql-jdbc3.jar"); try { copy("{$SYS["ROOT"]}/JasperReports/phpjasper/Pool/{$nomReport}.jrxml", "/tmp/{$nomReport}.jrxml"); $jcm = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager"); $report = $jcm->compileReport("/tmp/{$nomReport}.jrxml"); $jfm = new JavaClass("net.sf.jasperreports.engine.JasperFillManager"); $Conn = new Java("org.altic.jasperReports.JdbcConnection"); $Conn->setDriver("org.postgresql.Driver"); $Conn->setConnectString("jdbc:mysql://{$_SERVER["SERVER_NAME"]}:3306/{$SYS["mysql"]["DBNAME"]}"); // Parche tonto // $Conn->setConnectString("jdbc:postgresql://localhost:5432/{$_SESSION['dbname']}"); // $Conn->setUser("ascore"); $Conn->setPassword("ascore"); if ($Conn->getConnection()) { $parameters = new Java("java.util.HashMap"); /* PARAMETROS */ foreach ($arrParam as $n => $v) { // Tendré que comprobar el tipo, pasar ad_reference_id por parámetro if (isset($v['type'])) { if ($v['type'] == "Date") { $ts1 = text_to_int($v['value']); $JAVA_PAR = new Java("java.util.Date", date("Y", $ts1) - 1900, date("m", $ts1) - 1, date("d", $ts1)); $parameters->put($n, $JAVA_PAR); } else { if ($v['type'] == "Integer") { $JAVA_PAR = new Java("java.lang.Integer", $v['value']); //die( "NOMBRE PARAM: $n ; VALOR: {$v['value']} <br />"); $parameters->put($n, $JAVA_PAR); } else { if ($v['type'] == "Boolean") { $JAVA_PAR = new Java("java.lang.Boolean", $v['value']); $parameters->put($n, $JAVA_PAR); } else { if ($v['type'] == "Double") { $JAVA_PAR = new Java("java.lang.Double", $v['value']); $parameters->put($n, $JAVA_PAR); } else { $parameters->put($n, $v['value']); } } } } } else { $parameters->put($n, $v['value']); } } $parameters->put("REPORT_DIR", "/tmp/tmp/"); $print = $jfm->fillReport($report, $parameters, $Conn->getConnection()); $listaPag = $print->getPages(); $numPag = $listaPag->size(); if ($numPag == '0') { // Mostramos mensaje, el documento no contiene páginas (Usar div similar al session caducada) $_SESSION['msgDocInfo'] = "El documento no tiene páginas."; } else { $filem = time(); $finalname = "/tmp/{$filem}.pdf"; $jem = new JavaClass("net.sf.jasperreports.engine.JasperExportManager"); $jem->exportReportToPdfFile($print, $finalname); while (ob_end_clean()) { } if (file_exists($finalname)) { header('Content-type: application/pdf'); header("Content-Disposition: attachment; filename=\"{$finalname}\""); readfile($finalname); } die; } } else { echo "ERRORS"; } } catch (JavaException $ex) { /*$trace = new Java("java.io.ByteArrayOutputStream"); $ex->printStackTrace(new Java("java.io.PrintStream", $trace)); print "java stack trace: $trace\n";*/ ob_end_clean(); echo "<pre>ERROR<br>"; echo "Cause: " . $ex->getCause() . "<br>"; echo "Message: " . $ex->getMessage() . "</pre>"; } }
define('JAVA_INC_URL', 'http://localhost:85/JavaBridge/java/Java.inc'); require_once JAVA_INC_URL; //require_once("http://127.0.0.1:85/JavaBridge/java/Java.inc"); $system = new Java('java.lang.System'); $class = new JavaClass("java.lang.Class"); $class->forName("com.microsoft.sqlserver.jdbc.SQLServerDriver"); //$class->forName("com.mysql.jdbc.Driver"); $driverManager = new JavaClass("java.sql.DriverManager"); //$conn = $driverManager->getConnection("jdbc:mysql://localhost/stdb?user=sa&password=Tamakogi2012"); $conn = $driverManager->getConnection("jdbc:sqlserver://127.0.0.1;databaseName=st;user=sa;password=Tamakogi2012"); //compliler $compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager"); $viewer = new JavaClass("net.sf.jasperreports.view.JasperViewer"); $report = $compileManager->compileReport("C:/inetpub/wwwroot/inv_01.jrxml"); //fill $fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager"); $params = new Java("java.util.HashMap"); //$params->put("text", "Text"); $params->put("ofYear", 2015.0); //$params->put("date", convertValue("2007-12-31 0:0:0", "java.sql.Timestamp")); $emptyDatasource = new JavaClass("net.sf.jasperreports.engine.JREmptyDataSource"); $jasperPrint = $fillManager->fillReport($report, $params, $conn); $exportManager = new JavaClass("net.sf.jasperreports.engine.JasperExportManager"); $outputPath = realpath(".") . "/" . "output.pdf"; //$exportManager->exportReportToHtml($jasperPrint,$outputPath); //header("Content-type: application/html"); $exportManager->exportReportToPdfFile($jasperPrint, $outputPath); header("Content-type: application/pdf"); readfile($outputPath); unlink($outputPath);
function prepareParameters($parameters) { $params = array(); // build a params array as base to json encoding if (is_array($parameters)) { foreach ($parameters as $pn => $pv) { $params[$pn] = is_object($pv) ? $pv->__toString() : $pv; } } $p = new Java("java.util.HashMap"); foreach ($params as $pn => $pv) { $prefix = substr($pn, 0, 4); $name = substr($pn, 4); if ($prefix == 'int_') { $p->put($name, $this->convertValue($pv, "java.lang.Integer")); } else { if ($prefix == 'dbl_') { $p->put($name, $this->convertValue($pv, "java.lang.Double")); } else { if ($prefix == 'boo_') { $p->put($name, $this->convertValue($pv, "java.lang.Boolean")); } else { if ($prefix == 'str_') { $p->put($name, $this->convertValue($pv, "java.lang.String")); } else { if ($prefix == 'stm_') { $p->put($name, $this->convertValue($pv, "java.io.InputStream")); } else { $p->put($pn, $this->convertValue($pv, "java.lang.String")); } } } } } } return $p; }
} } $bandSchema = 0; if (!empty($_REQUEST['bandschema'])) { $bandSchema = intval($_REQUEST['bandschema']); } // Request parsing is completed.. Act according to what has been requested if ($requestType == 'json' && empty($pointsOfInterest)) { sendJsonResponse(array(), $timestamp, $timestamp2, "No latlon specified in request"); exit(0); } $bandHelper = new DiscreteBandHelper(DiscreteBandHelper::LABEL_TYPE_BAND, $bandSchema); $ozoneBand = $bandHelper->getBand(); $bandHashMap = new Java("java.util.HashMap"); foreach ($ozoneBand as $key => $val) { $bandHashMap->put($key, doubleval($val)); } $queryManager = new QueryManager(); $start = microtime(true); $grid = array(); $queryTime = 0; $driver = new Java('LatLongInterpolation.LatLngDriver', $bandHashMap); for ($t = $timestamp; $t <= $timestamp2; $t += $interval) { $queryStart = microtime(true); $loadedData = $queryManager->getPointData($t, $pointsOfInterest, $gridReference); $queryTime += microtime(true) - $queryStart; if (!empty($loadedData)) { $latlngData = array(); // count($pointsOfInterest) should be same as count($loadedData) for ($i = 0; $i < count($pointsOfInterest); $i++) { $labelId = $bandHelper->getLabelId($loadedData[$i]['o3']);
public function report_TRN1I060() { $get_data = $this->input->get(NULL, TRUE); if (empty($get_data) === FALSE) { $this->checkJavaExtension(); $compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager"); // $report = $compileManager->compileReport("C:/DPE/apache-tomcat-6.0.32/reports/TRN1I040_Regis_v2.jrxml"); $fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager"); // Add parameters // p_termId // p_historyNoStart // p_historyNoEnd $params = new Java("java.util.HashMap"); $str_term_id = (string) $get_data['TERM_GEN']; $params->put("p_termId", $str_term_id); if ($get_data['HISTORY_NO'] === '1') { $str_history_no_start = (string) $get_data['HISTORY_NO_START']; $params->put("p_historyNoStart", $str_history_no_start); $str_history_no_end = (string) $get_data['HISTORY_NO_END']; $params->put("p_historyNoEnd", $str_history_no_end); } $class = new JavaClass("java.lang.Class"); $class->forName("oracle.jdbc.driver.OracleDriver"); $driverManager = new JavaClass("java.sql.DriverManager"); $conn = $driverManager->getConnection("jdbc:oracle:thin:@192.168.2.13:1521:OSRDDB2", "train", "train"); // $emptyDataSource = new Java("net.sf.jasperreports.engine.JREmptyDataSource"); // $jasperPrint = $fillManager->fillReport($report, $params, $conn); $report_name = ''; if ($get_data['REPORT_TYPE'] === 'vertical') { $report_name = 'TRN1I060_Certifys_Vertical.jasper'; } else { if ($get_data['REPORT_TYPE'] === 'horizontal') { $report_name = 'TRN1I060_Certifys.jasper'; } } $jasperPrint = $fillManager->fillReport("C:/DPE/apache-tomcat-6.0.32/reports/" . $report_name, $params, $conn); $filename = uniqid('Report_'); $outputPath = "E:/dd/" . "{$filename}.pdf"; $exportManager = new JavaClass("net.sf.jasperreports.engine.JasperExportManager"); $exportManager->exportReportToPdfFile($jasperPrint, $outputPath); header("Content-type: application/pdf"); readfile($outputPath); unlink($outputPath); } }
function clearreports_get_request_properties($get, $post) { $p = new Java("java.util.Properties"); foreach ($post as $key => $val) { $p->put($key, $val); } foreach ($get as $key => $val) { $p->put($key, $val); } // Add the client language that the browser has sent. Useful for // multi-language reports. $p->put("locale", array_key_exists('HTTP_ACCEPT_LANGUAGE', $_SERVER) ? $_SERVER['HTTP_ACCEPT_LANGUAGE'] : "en"); if (array_key_exists('PATH_INFO', $_SERVER)) { $reportname = $_SERVER['PATH_INFO']; $p->put("reportname", java_values($reportname)); } return $p; }
function reporte($id = null) { require_once "http://localhost:8080/JavaBridge/java/Java.inc"; $parteId = $id; $params = new Java("java.util.HashMap"); $params->put("parteid", $parteId); try { $jasperxml = new java("net.sf.jasperreports.engine.xml.JRXmlLoader"); $jasperDesign = $jasperxml->load(realpath("InformedePartes.jrxml")); $query = new java("net.sf.jasperreports.engine.design.JRDesignQuery"); $query->setText("select u.username, p.* ,t.inicial as tinicial, t.final as tfinal, t.entrada as tentrada, t.salida as tsalida,\n\t\t\t\t\t\t\tr.inicial as rinicial, r.final as rfinal, r.entrada as rentrada, r.salida as rsalida,\n\t\t\t\t\t\t\te.inicial as einicial, e.final as efinal,\n\t\t\t\t\t\t\te2.entrada as eeentrada, e2.salida as eesalida, e2.inicial as eeinicial, e2.final as eefinal\n\t\t\t\t\t\tfrom partes p , textos t ,reales r , enteros e, enteros e2, users u\n\t\t\t\t\t\twhere p.id=t.parte_id and p.id=r.parte_id and p.id=e.parte_id and p.id=e2.parte_id and p.id={$parteId}\n\t\t\t\t\t\tand e.tipocampos_tipoparte_id=2 and e2.tipocampos_tipoparte_id=6 and u.id=p.usuariovendedor;"); $jasperDesign->setQuery($query); $compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager"); $report = $compileManager->compileReport($jasperDesign); } catch (JavaException $ex) { echo $ex; } $fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager"); $class = new JavaClass("java.lang.Class"); $class->forName("com.mysql.jdbc.Driver"); $driverManager = new JavaClass("java.sql.DriverManager"); //db username and password $conn = $driverManager->getConnection("jdbc:mysql://localhost:3306/estacion?zeroDateTimeBehavior=convertToNull", "root", ""); $jasperPrint = $fillManager->fillReport($report, $params, $conn); $exporter = new java("net.sf.jasperreports.engine.JRExporter"); $outputPath = realpath(".") . "\\" . "InformedePartes.pdf"; $exporter = new java("net.sf.jasperreports.engine.export.JRPdfExporter"); $exporter->setParameter(java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint); $exporter->setParameter(java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath); header("Content-type: application/pdf"); header("Content-Disposition: attachment; filename=InformedePartes.pdf"); $exporter->exportReport(); readfile($outputPath); unlink($outputPath); }
$report = $jcm->compileReport($URLBASE . $informe . ".jrxml"); try { $jfm = new JavaClass("net.sf.jasperreports.engine.JasperFillManager"); $Conn = new Java("org.altic.jasperReports.JdbcConnection"); $Conn->setDriver("com.mysql.jdbc.Driver"); $Conn->setConnectString("jdbc:mysql://localhost:3306/{$SYS["mysql"]["DBNAME"]}"); $Conn->setUser($SYS["mysql"]["DBUSER"]); $Conn->setPassword($SYS["mysql"]["DBPASS"]); if ($Conn->getConnection()) { $parameters = new Java("java.util.HashMap"); foreach ($P as $k => $v) { if ($v["paratype"] == "Fecha") { ereg("([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})", $v["value"], $bloques); $ts1 = strtotime($bloques[3] . "-" . $bloques[2] . "-" . $bloques[1]); $JAVA_PAR = new Java("java.util.Date", date("y", $ts1) + 100, date("m", $ts1) - 1, date("d", $ts1)); $parameters->put($v["paraname"], $JAVA_PAR); } else { if ($v["paratype"] == "Entero") { $JAVA_PAR = new Java("java.lang.Integer", (int) $v["value"]); $parameters->put($v["paraname"], $JAVA_PAR); //$parameters->put($v["paraname"],$JAVA_PAR); } else { if ($v["paratype"] == "Cadena") { $JAVA_PAR = new Java("java.lang.String", $v["value"]); $parameters->put($v["paraname"], $JAVA_PAR); } } } } $parameters->put("REPORT_DIR", $URLBASE); $print = $jfm->fillReport($report, $parameters, $Conn->getConnection());
function reporte() { require_once "http://localhost:8080/JavaBridge/java/Java.inc"; try { $jasperxml = new java("net.sf.jasperreports.engine.xml.JRXmlLoader"); $jasperDesign = $jasperxml->load(realpath("InformedeUsuarios.jrxml")); $query = new java("net.sf.jasperreports.engine.design.JRDesignQuery"); $query->setText("select users.*, roles.name\n\t\t\t\t\tfrom users INNER JOIN roles ON users.role_id=roles.id"); $jasperDesign->setQuery($query); $compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager"); $report = $compileManager->compileReport($jasperDesign); } catch (JavaException $ex) { echo $ex; } $fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager"); $params = new Java("java.util.HashMap"); $params->put("title", "Customer"); $class = new JavaClass("java.lang.Class"); $class->forName("com.mysql.jdbc.Driver"); $driverManager = new JavaClass("java.sql.DriverManager"); //db username and password $conn = $driverManager->getConnection("jdbc:mysql://localhost:3306/estacion?zeroDateTimeBehavior=convertToNull", "root", ""); $jasperPrint = $fillManager->fillReport($report, $params, $conn); $exporter = new java("net.sf.jasperreports.engine.JRExporter"); $outputPath = realpath(".") . "\\" . "InformedeUsuarios.pdf"; $exporter = new java("net.sf.jasperreports.engine.export.JRPdfExporter"); $exporter->setParameter(java("net.sf.jasperreports.engine.JRExporterParameter")->JASPER_PRINT, $jasperPrint); $exporter->setParameter(java("net.sf.jasperreports.engine.JRExporterParameter")->OUTPUT_FILE_NAME, $outputPath); header("Content-type: application/pdf"); header("Content-Disposition: attachment; filename=InformedeUsuarios.pdf"); $exporter->exportReport(); readfile($outputPath); unlink($outputPath); }
function cetak($rpt, $param_data = array(), $type = "pdf", $ignore_html_pg = TRUE) { error_reporting(E_ALL); ini_set('display_errors', 'On'); $checkJavaExt = $this->checkJavaExtension(); if (!$checkJavaExt) { return $checkJavaExt; } // $rpt = 'simple'; // $report = dirname(__FILE__)."//..//modules//".active_module()."//reports//{$rpt}.jasper"; // $reportx = dirname(__FILE__)."//..//modules//".active_module()."//reports//{$rpt}.jrxml"; $outputPath = dirname(__FILE__) . "//..//modules//" . active_module() . "//reports//{$rpt}"; $reportx = dirname(__FILE__) . "//..//modules//" . active_module() . "//reports//{$rpt}.jrxml"; // $outputPath = sys_get_temp_dir()."//{$rpt}"; //buang ke tmp ajah // die ($reportx); $compileManager = new JavaClass("net.sf.jasperreports.engine.JasperCompileManager"); $report = $compileManager->compileReport($reportx); $params = new Java("java.util.HashMap"); foreach ($param_data as $prm => $val) { $params->put($prm, $val); } // if ($type=="html") { if ($ignore_html_pg == TRUE) { $params->put("IS_IGNORE_PAGINATION", true); } java('java.lang.Class')->forName('org.postgresql.Driver'); $conn = java('java.sql.DriverManager')->getConnection("jdbc:postgresql://localhost:{$this->port}/{$this->db}?user={$this->usr}&password={$this->pwd}"); $emptyDataSource = new Java("net.sf.jasperreports.engine.JREmptyDataSource"); $fillManager = new JavaClass("net.sf.jasperreports.engine.JasperFillManager"); $jasperPrint = $fillManager->fillReport($report, $params, $conn); /* */ // bagus niy cm kayanya bakal tampil diserver.. hmmm nanti dah // $viewer = new JavaClass("net.sf.jasperreports.view.JasperViewer"); // $viewer->viewReport($jasperPrint, false); // $conn->close(); // die(); /* */ $exportManager = new JavaClass("net.sf.jasperreports.engine.JasperExportManager"); if ($type == "html") { $exportManager->exportReportToHtmlFile($jasperPrint, $outputPath); header("Content-type: text/html"); } else { $exportManager->exportReportToPdfFile($jasperPrint, $outputPath); header("Content-type: application/pdf"); // paksa donlot ? // header('Content-Disposition: attachment;filename="' . $rpt . '.pdf"'); } /* */ // oh buat ngeprint... // $printManager = new JavaClass("net.sf.jasperreports.engine.JasperPrintManager"); // $printManager->printPages($jasperPrint, 0,0, true); /* */ readfile($outputPath); @unlink($outputPath); $conn->close(); }