diff --git a/composer.json b/composer.json index c4ca5c6..616f20a 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "cossou/jasperphp", + "name": "fazo96/jasperphp", "description": "Create Reports in PHP with JasperReports", "license": "MIT", "keywords": [ @@ -10,11 +10,15 @@ "pdf", "java" ], - "homepage": "https://github.com/cossou/JasperPHP", + "homepage": "https://github.com/fazo96/JasperPHP", "authors": [ { "name": "Hélder Duarte", "email": "cossou@gmail.com" + }, + { + "name": "Enrico Fasoli", + "email": "enrico.fasoli1996@gmail.com" } ], "autoload": { diff --git a/src/JasperPHP/JasperPHP.php b/src/JasperPHP/JasperPHP.php index 8a06c89..62e6ce3 100644 --- a/src/JasperPHP/JasperPHP.php +++ b/src/JasperPHP/JasperPHP.php @@ -14,7 +14,7 @@ class JasperPHP function __construct($resource_dir = false) { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') - $this->windows = true; + $this->windows = true; if (!$resource_dir) { $this->resource_directory = __DIR__ . "/../../../../../"; @@ -56,7 +56,7 @@ public function compile($input_file, $output_file = false, $background = true, $ return $this; } - public function process($input_file, $output_file = false, $format = array("pdf"), $parameters = array(), $db_connection = array(), $background = true, $redirect_output = true) + public function process($input_file, $output_file = false, $format = array("pdf"), $parameters = array(), $db_connection = array(), $locale = false, $resourceDir = false, $background = true, $redirect_output = true) { if(is_null($input_file) || empty($input_file)) throw new \Exception("No input file", 1); @@ -70,11 +70,13 @@ public function process($input_file, $output_file = false, $format = array("pdf" } } else { if( !in_array($format, $this->formats)) - throw new \Exception("Invalid format!", 1); + throw new \Exception("Invalid format!", 1); } $command = __DIR__ . $this->executable; + if(!empty($locale)) $command .= ' --locale ' . $locale . ' '; + $command .= " process "; $command .= $input_file; @@ -88,7 +90,8 @@ public function process($input_file, $output_file = false, $format = array("pdf" $command .= " -f " . $format; // Resources dir - $command .= " -r " . $this->resource_directory; + if (empty($resourceDir)) $resourceDir = $this->resource_directory; + $command .= " -r " . $resourceDir; if( count($parameters) > 0 ) { @@ -122,7 +125,7 @@ public function process($input_file, $output_file = false, $format = array("pdf" if( isset($db_connection['jdbc_url']) && !empty($db_connection['jdbc_url']) ) $command .= " --db-url " . $db_connection['jdbc_url']; - if ( isset($db_connection['jdbc_dir']) && !empty($db_connection['jdbc_dir']) ) + if ( isset($db_connection['jdbc_dir']) && !empty($db_connection['jdbc_dir']) ) $command .= ' --jdbc-dir ' . $db_connection['jdbc_dir']; if ( isset($db_connection['db_sid']) && !empty($db_connection['db_sid']) ) @@ -176,10 +179,10 @@ public function execute($run_as_user = false) if( $return_var != 0 && isset($output[0]) ) throw new \Exception($output[0], 1); - - elseif( $return_var != 0 ) + + elseif( $return_var != 0 ) throw new \Exception("Your report has an error and couldn't be processed! Try to output the command using the function `output();` and run it manually in the console.", 1); - + return $output; } }