Skip to content

Commit c27fc13

Browse files
author
Daniel Rodrigues Lima
committed
add locale
1 parent 9eecd2d commit c27fc13

File tree

3 files changed

+48
-32
lines changed

3 files changed

+48
-32
lines changed

README.md

Lines changed: 43 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Reports for PHP and Laravel 5.*, with JasperReports.
22

3-
[![License](https://poser.pugx.org/lavela/phpjasper/license)](https://packagist.org/packages/lavela/phpjasper) [![Total Downloads](https://poser.pugx.org/lavela/phpjasper/downloads)](https://packagist.org/packages/lavela/phpjasper)
3+
[![Latest Stable Version](https://poser.pugx.org/geekcom/phpjasper/v/stable)](https://packagist.org/packages/geekcom/phpjasper)
4+
[![License](https://poser.pugx.org/geekcom/phpjasper/license)](https://packagist.org/packages/geekcom/phpjasper) [![Total Downloads](https://poser.pugx.org/geekcom/phpjasper/downloads)](https://packagist.org/packages/geekcom/phpjasper)
45

56
**Is using Linux servers?**
67

7-
Do not forget to grant permission 777 for the directory **/vendor/lavela/phpjasper/src/JasperStarter/bin** and the file binary **jasperstarter**
8+
Do not forget to grant permission 777 for the directory **/vendor/geekcom/phpjasper/src/JasperStarter/bin** and the file binary **jasperstarter**
89

910
##Introduction
1011

@@ -84,14 +85,14 @@ Now run the `java -version` again and check if the output is ok.
8485

8586
2. Install [Composer](http://getcomposer.org) if you don't have it.
8687
```
87-
composer require lavela/phpjasper
88+
composer require geekcom/phpjasper
8889
```
8990
Or in your 'composer.json' file add:
9091

9192
```javascript
9293
{
9394
"require": {
94-
"lavela/phpjasper": "1.*"
95+
"geekcom/phpjasper": "1.*"
9596
}
9697
}
9798
```
@@ -106,7 +107,7 @@ and thats it.
106107

107108
###The *Hello World* example.
108109

109-
Go to the examples directory in the root of the repository (`vendor/lavela/phpjasper/examples`).
110+
Go to the examples directory in the root of the repository (`vendor/geekcom/phpjasper/examples`).
110111
Open the `hello_world.jrxml` file with Jaspersoft Studio or with your favorite text editor and take a look at the source code.
111112

112113
#### Compiling
@@ -121,7 +122,7 @@ require __DIR__ . '/vendor/autoload.php';
121122

122123
use JasperPHP\JasperPHP;
123124

124-
$input = __DIR__ . '/vendor/lavela/phpjasper/examples/hello_world.jrxml';
125+
$input = __DIR__ . '/vendor/geekcom/phpjasper/examples/hello_world.jrxml';
125126

126127
$jasper = new JasperPHP;
127128
$jasper->compile($input)->execute();
@@ -139,8 +140,8 @@ require __DIR__ . '/vendor/autoload.php';
139140

140141
use JasperPHP\JasperPHP;
141142

142-
$input = __DIR__ . '/vendor/lavela/phpjasper/examples/hello_world.jasper';
143-
$output = __DIR__ . '/vendor/lavela/phpjasper/examples';
143+
$input = __DIR__ . '/vendor/geekcom/phpjasper/examples/hello_world.jasper';
144+
$output = __DIR__ . '/vendor/geekcom/phpjasper/examples';
144145

145146
$jasper = new JasperPHP;
146147

@@ -165,7 +166,7 @@ require __DIR__ . '/vendor/autoload.php';
165166

166167
use JasperPHP\JasperPHP;
167168

168-
$input = __DIR__ . '/vendor/lavela/phpjasper/examples/hello_world_params.jrxml';
169+
$input = __DIR__ . '/vendor/geekcom/phpjasper/examples/hello_world_params.jrxml';
169170

170171
$jasper = new JasperPHP;
171172
$output = $jasper->list_parameters($input)->execute();
@@ -184,37 +185,50 @@ require __DIR__ . '/vendor/autoload.php';
184185

185186
use JasperPHP\JasperPHP;
186187

187-
$input = __DIR__ . '/vendor/lavela/phpjasper/examples/hello_world.jrxml';
188-
$output = __DIR__ . '/vendor/lavela/phpjasper/examples';
188+
$input = __DIR__ . '/vendor/geekcom/phpjasper/examples/hello_world.jrxml';
189+
$output = __DIR__ . '/vendor/geekcom/phpjasper/examples';
190+
191+
private $conn;
192+
193+
public function __construct()
194+
{
195+
$this->conn = [
196+
'driver' => 'postgres',
197+
'username' => 'DB_USERNAME',
198+
'password' => 'DB_PASSWORD',
199+
'host' => 'DB_HOST',
200+
'database' => 'DB_DATABASE',
201+
'schema' => 'DB_SCHEMA',
202+
'port' => '5432'
203+
];
204+
}
189205

190206
$jasper = new JasperPHP;
207+
191208
$jasper->process(
192-
$input,
193-
$output,
194-
array("pdf", "rtf"),
195-
array("php_version" => phpversion()),
196-
array(
197-
'driver' => 'postgres',
198-
'username' => 'vagrant',
199-
'host' => 'localhost',
200-
'database' => 'samples',
201-
'port' => '5432',
202-
)
209+
$input,
210+
$output,
211+
array("pdf", "rtf"),
212+
array("php_version" => phpversion()),
213+
$this->conn,
214+
true,
215+
true,
216+
'pt_BR' //LOCALE
203217
)->execute();
204218
```
205219

206220
###Using JasperPHP with Laravel 5.*
207221

208222
1. Install [Composer](http://getcomposer.org) if you don't have it.
209223
```
210-
composer require lavela/phpjasper
224+
composer require geekcom/phpjasper
211225
```
212226
Or in your 'composer.json' file add:
213227

214228
```javascript
215229
{
216230
"require": {
217-
"lavela/phpjasper": "1.*"
231+
"geekcom/phpjasper": "1.*"
218232
}
219233
}
220234
```
@@ -228,7 +242,7 @@ Or in your 'composer.json' file add:
228242

229243
4. Create a folder **/report** on **/public directory**
230244

231-
5. Copy the file **hello_world.jrxml** in **/vendor/lavela/phpjasper/examples** from directory: **/public/report**
245+
5. Copy the file **hello_world.jrxml** in **/vendor/geekcom/phpjasper/examples** from directory: **/public/report**
232246

233247
6. Run **php artisan serve**
234248

@@ -298,9 +312,9 @@ public function xmlToPdf()
298312

299313
To use the example above you must copy the sample files located at:
300314

301-
**\vendor\lavela\phpjasper\examples\CancelAck.jrxml**
315+
**\vendor\geekcom\phpjasper\examples\CancelAck.jrxml**
302316
and
303-
**\vendor\lavela\phpjasper\examples\CancelAck.xml**
317+
**\vendor\geekcom\phpjasper\examples\CancelAck.xml**
304318
to folder:
305319
**\public\report**
306320

@@ -346,9 +360,9 @@ public function jsonToPdf()
346360

347361
To use the example above you must copy the sample files located at:
348362

349-
**\vendor\lavela\phpjasper\examples\json.jrxml**
363+
**\vendor\geekcom\phpjasper\examples\json.jrxml**
350364
and
351-
**\vendor\lavela\phpjasper\examples\contacts.json**
365+
**\vendor\geekcom\phpjasper\examples\contacts.json**
352366
to folder:
353367
**\public\report**
354368

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "lavela/phpjasper",
2+
"name": "geekcom/phpjasper",
33
"description": "Create Reports in PHP/Laravel with JasperReports",
44
"license": "MIT",
55
"keywords": [
@@ -12,7 +12,7 @@
1212
"java",
1313
"json"
1414
],
15-
"homepage": "https://github.com/lavela/phpjasper",
15+
"homepage": "https://github.com/geekcom/phpjasper",
1616
"authors": [
1717
{
1818
"name": "Leandro Bitencourt",

src/JasperPHP/JasperPHP.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function compile($input_file, $output_file = false, $background = true, $
6060
return $this;
6161
}
6262

63-
public function process($input_file, $output_file = false, $format = array('pdf'), $parameters = array(), $db_connection = array(), $background = true, $redirect_output = true)
63+
public function process($input_file, $output_file = false, $format = array('pdf'), $parameters = array(), $db_connection = array(), $background = true, $redirect_output = true, $locale = false )
6464
{
6565
if(is_null($input_file) || empty($input_file))
6666
throw new \Exception('No input file', 1);
@@ -79,6 +79,8 @@ public function process($input_file, $output_file = false, $format = array('pdf'
7979

8080
$command = ($this->windows) ? $this->executable : './' . $this->executable;
8181

82+
$command .= ($locale) ? " --locale $locale" : '';
83+
8284
$command .= ' process ';
8385

8486
$command .= "\"$input_file\"";

0 commit comments

Comments
 (0)