Skip to content

Commit

Permalink
Merge pull request #18 from Dericktan/patch-1
Browse files Browse the repository at this point in the history
Remove duplicate variable
  • Loading branch information
lavela authored Oct 15, 2016
2 parents 4b78565 + 7e644a0 commit aed60ee
Show file tree
Hide file tree
Showing 93 changed files with 5,363 additions and 3,092 deletions.
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Copyright (c) 2013 Hélder Duarte
Copyright (c) 2015 Leandro Bitencourt
Copyright (c) 2015 Daniel Rodrigues
Copyright (c) 2015 Jefferson Barreto
Copyright (c) 2016 Derick Tan

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
111 changes: 83 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# JasperReports for PHP and Laravel Framework

[![Latest Stable Version](https://poser.pugx.org/lavela/phpjasper/v/stable)](https://packagist.org/packages/lavela/phpjasper) [![Latest Unstable Version](https://poser.pugx.org/lavela/phpjasper/v/unstable)](https://packagist.org/packages/lavela/phpjasper) [![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)
[![Latest Stable Version](https://poser.pugx.org/dericktan/phpjasper/v/stable)](https://packagist.org/packages/dericktan/phpjasper)
[![License](https://poser.pugx.org/dericktan/phpjasper/license)](https://packagist.org/packages/dericktan/phpjasper)
[![Monthly Downloads](https://poser.pugx.org/dericktan/phpjasper/d/monthly)](https://packagist.org/packages/dericktan/phpjasper)
[![Total Downloads](https://poser.pugx.org/dericktan/phpjasper/downloads)](https://packagist.org/packages/dericktan/phpjasper)

**Is using Linux servers?**

Do not forget to grant permission 777 for the directory **/vendor/lavela/phpjasper/src/JasperStarter/bin** and the file binary **jasperstarter**
Do not forget to grant permission 777 for the directory **/vendor/dericktan/phpjasper/src/JasperStarter/bin** and the file binary **jasperstarter**

##Introduction

Expand Down Expand Up @@ -71,14 +74,14 @@ Now run the `java -version` again and check if the output is ok.

Install [Composer](http://getcomposer.org) if you don't have it.
```
composer require lavela/phpjasper
composer require dericktan/phpjasper
```
Or in your 'composer.json' file add:

```javascript
{
"require": {
"lavela/phpjasper": "1.*"
"dericktan/phpjasper": "1.*"
}
}
```
Expand All @@ -93,7 +96,7 @@ and thats it.

###The *Hello World* example.

Go to the examples directory in the root of the repository (`vendor/lavela/phpjasper/examples`).
Go to the examples directory in the root of the repository (`vendor/dericktan/phpjasper/examples`).
Open the `hello_world.jrxml` file with iReport or with your favorite text editor and take a look at the source code.

#### Compiling
Expand All @@ -108,7 +111,7 @@ require __DIR__ . '/vendor/autoload.php';

use JasperPHP\JasperPHP;

$input = __DIR__ . '/vendor/lavela/phpjasper/examples/hello_world.jrxml';
$input = __DIR__ . '/vendor/dericktan/phpjasper/examples/hello_world.jrxml';

$jasper = new JasperPHP;
$jasper->compile($input)->execute();
Expand All @@ -126,8 +129,8 @@ require __DIR__ . '/vendor/autoload.php';

use JasperPHP\JasperPHP;

$input = __DIR__ . '/vendor/lavela/phpjasper/examples/hello_world.jasper';
$output = __DIR__;
$input = __DIR__ . '/vendor/dericktan/phpjasper/examples/hello_world.jasper';
$output = __DIR__;

$jasper = new JasperPHP;

Expand All @@ -152,7 +155,7 @@ require __DIR__ . '/vendor/autoload.php';

use JasperPHP\JasperPHP;

$input = __DIR__ . '/vendor/lavela/phpjasper/examples/hello_world_params.jrxml';
$input = __DIR__ . '/vendor/dericktan/phpjasper/examples/hello_world_params.jrxml';

$jasper = new JasperPHP;
$output = $jasper->list_parameters($input)->execute();
Expand All @@ -169,10 +172,10 @@ We can also specify parameters for connecting to database:

require __DIR__ . '/vendor/autoload.php';

use JasperPHP\JasperPHP;
use JasperPHP\JasperPHP;

$input = __DIR__ . '/vendor/lavela/phpjasper/examples/hello_world.jrxml';
$output = __DIR__;
$input = __DIR__ . '/vendor/dericktan/phpjasper/examples/hello_world.jrxml';
$output = __DIR__;

$jasper = new JasperPHP;
$jasper->process(
Expand All @@ -194,14 +197,14 @@ $jasper->process(

1. Install [Composer](http://getcomposer.org) if you don't have it.
```
composer require lavela/phpjasper
composer require dericktan/phpjasper
```
Or in your 'composer.json' file add:

```javascript
{
"require": {
"lavela/phpjasper": "1.*"
"dericktan/phpjasper": "1.*"
}
}
```
Expand All @@ -215,7 +218,7 @@ Or in your 'composer.json' file add:

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

5. Copy the file **hello_world.jrxml** in **/vendor/lavela/phpjasper/examples** from directory: **/public/report**
5. Copy the file **hello_world.jrxml** in **/vendor/dericktan/phpjasper/examples** from directory: **/public/report**

6. Run **php artisan serve**

Expand All @@ -229,12 +232,12 @@ Or in your 'composer.json' file add:
use JasperPHP\JasperPHP;

Route::get('/reports', function () {

$output = public_path() . '/report/'.time().'_hello_world';
$report = new JasperPHP;
$report->process(
public_path() . '/report/hello_world.jrxml',
$output,
public_path() . '/report/hello_world.jrxml',
$output,
array('pdf', 'rtf', 'xml'),
array(),
array()
Expand All @@ -254,23 +257,22 @@ use JasperPHP\JasperPHP;

public function xmlToPdf()
{
$output = public_path() . '/report/'.time().'_CancelAck';
$output = public_path() . '/report/'.time().'_CancelAck';
$ext = "pdf";
$data_file = public_path() . '/report/CancelAck.xml';
$driver = 'xml';
$xml_xpath = '/CancelResponse/CancelResult/ID';
\JasperPHP::process(
public_path() . '/report/CancelAck.jrxml',
$output,
$jasper = new JasperPHP;
$jasper->process(
public_path() . '/report/CancelAck.jrxml',
$output,
array($ext),
array(),
array('data_file' => $data_file, 'driver' => $driver, 'xml_xpath' => $xml_xpath),
false,
false
)->execute();

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.time().'_CancelAck.'.$ext);
Expand All @@ -284,16 +286,67 @@ public function xmlToPdf()

}
```
**Note:**
**Note:**

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

**\vendor\lavela\phpjasper\src\JasperStarter\examples\CancelAck.jrxml**
**\vendor\dericktan\phpjasper\src\JasperStarter\examples\CancelAck.jrxml**
and
**\vendor\lavela\phpjasper\src\JasperStarter\examples\CancelAck.xml**
**\vendor\dericktan\phpjasper\src\JasperStarter\examples\CancelAck.xml**
to folder:
**\public\report**
**\public\report**

###Additional Information - Reports from a xml in Laravel 5.2

See how easy it is to generate a report with a source an json file:

```php

use JasperPHP\JasperPHP;

public function jsonToPdf()
{
$output = public_path() . '/report/'.time().'_Contacts';
$ext = "pdf";
$driver = 'json';
$json_query= "contacts.person";
$data_file = public_path() . '/report/contacts.json';

$jasper = new JasperPHP;
$jasper->process(
public_path() . '/report/json.jrxml',
$output,
array($ext),
array(),
array(
'driver' => $driver,
'json_query' => $json_query,
'data_file' => $data_file
)
)->execute();

header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.time().'_CancelAck.'.$ext);
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-Length: ' . filesize($output.'.'.$ext));
flush();
readfile($output.'.'.$ext);
unlink($output.'.'.$ext);

}
```
**Note:**

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

**\vendor\dericktan\phpjasper\src\JasperStarter\examples\CancelAck.jrxml**
and
**\vendor\dericktan\phpjasper\src\JasperStarter\examples\CancelAck.xml**
to folder:
**\public\report**

###MySQL

Expand Down Expand Up @@ -321,6 +374,8 @@ Drop me a line on Skype [danielrodrigueslima] or E-Mail [danielrodrigues-ti@hotm

Drop me a line on E-Mail [[email protected]]

Drop me a line on E-Mail [[email protected]]

##License

MIT
16 changes: 11 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "lavela/phpjasper",
"name": "dericktan/phpjasper",
"description": "Create Reports in PHP with JasperReports",
"license": "MIT",
"keywords": [
Expand All @@ -8,11 +8,12 @@
"jasperreports",
"reports",
"pdf",
"xml",
"PHP",
"java"
"xml",
"PHP",
"java",
"json"
],
"homepage": "https://github.com/lavela/phpjasper",
"homepage": "https://github.com/Dericktan/phpjasper",
"authors": [
{
"name": "Leandro Bitencourt",
Expand All @@ -29,6 +30,11 @@
"name": "Jefferson Barreto",
"email": "[email protected]",
"role": "Developer"
},
{
"name": "Derick Tan",
"email": "[email protected]",
"role": "Developer"
}
],
"minimum-stability": "dev",
Expand Down
24 changes: 24 additions & 0 deletions examples/contacts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"contacts": {
"person": [
{
"name": "ETHAN",
"street": "Street 1",
"city": "Fairfax",
"phone": "+1 (415) 111-1111"
},
{
"name": "CALEB",
"street": "Street 2",
"city": "San Francisco",
"phone": "+1 (415) 222-2222"
},
{
"name": "WILLIAM",
"street": "Street 2",
"city": "Paradise City",
"phone": "+1 (415) 333-3333"
}
]
}
}
Loading

0 comments on commit aed60ee

Please sign in to comment.