-2
I’m doing a monthly report of an application with Laravel 5.7, but it’s only returning NULL from the database. I’m using Mysql. Can someone help us? This is my Controller.
use Illuminate\Http\Request;
use PHPJasper\PHPJasper;
use App\Model\User;
class ReportController extends Controller
{
public function index()
{
$output = public_path() . '/reports/' . time() . '_MidiaSocial';
$input = public_path().'/reports/Sistema.jrxml';
$report = new PHPJasper;
$report->process(
$input,
$output,
array("pdf"),
array(),
[
'driver' => 'generic',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'calculosorte'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'jdbc_driver' => 'com.mysql.jdbc.Driver',
'jdbc_url' => 'jdbc:mysql://'.env('DB_HOST', 'localhost').':'.env('DB_PORT', '3306').';databaseName='.env('DB_DATABASE', 'calculosorte'),
'jdbc_dir' => base_path().env('JDBC_DIR', 'vendor/geekcom/phpjasper/bin/jasperstarter/jdbc/')
]
)->execute();
$file = $output.'.pdf';
$path = $file;
if (!file_exists($file)) {
abort(404);
}
//caso tenha sido gerado pego o conteudo
$file = file_get_contents($file);
//deleto o arquivo gerado, pois iremos mandar o conteudo para o navegador
unlink($path);
// retornamos o conteudo para o navegador que íra abrir o PDF
return response($file, 200)
->header('Content-Type', 'application/pdf')
->header('Content-Disposition', 'inline; filename="midia_social.pdf"');
}
}
Phpjasper Phpjasper Object([command:protected] => jasperstarter --locale pt_BR process "C: wamp64 www personal lottery public/Reports/Biggoldloto.jrxml" -o "C: wamp64 www personal lottery public/Reports/" -f pdf -t mysql -u root -p -H localhost -n calculosorte --db-port 3306 --db-driver com.mysql.jdbc.Driver --db-url jdbc:mysql:/127.0.0.1:3306;databaseName=calculosorte --jdbc-dir
– G. J
C:\wamp64\www\pessoal\loteriavendor/geekcom/phpjasper/bin/jasperstarter/jdbc/
[executable:protected] => jasperstarter
[pathExecutable:protected] => C:\wamp64\www\pessoal\loteria\vendor\geekcom\phpjasper\src/.. /bin/jasperstarter/bin [windows:protected] => 1 [formats:protected] => Array ([0] => pdf [1] => rtf [2] => xls [3] => xlsx [4] => docx [5] => odt [6] => ods [7] => pptx [8] => csv [9] => html [10] => xhtml [11] => xml [12] => jrprint))
– G. J
You gave this when you run the example above. Do you have any idea how to solve?
– G. J
My Code looks like this: $input = public_path(). '/Reports/System.jrxml'; $output = public_path(). '/Reports/'; $options = [ 'format' => ['pdf'], 'locale' => 'pt_BR', 'params' => [], 'db_connection' => [ 'driver' => 'mysql', 'username' => 'root', 'password' => ', 'host' => 'localhost', 'database' => 'calculosorte', 'port' => '3306', 'jdbc_driver' => 'com.mysql.jdbc.Driver', 'jdbc_url' => 'jdbc:mysql://'. env('DB_HOST', 'localhost'). ':'. env('DB_PORT', '3306'). ';databaseName='. env('DB_DATABASE', 'calculosorte'),
– G. J
'jdbc_dir' => base_path(). env('JDBC_DIR', 'vendor/geekcom/phpjasper/bin/jasperstarter/jdbc/')]]; $Jasper = new Phpjasper; $Jasper->process($input,$output,$options)->output();
– G. J
You are using Laravel the only time I made it exactly like this https://medium.com/@eltonantunes_85873/relat%C3%B3rios-em-php-Laravel-com-jasperreports-parte-1-9a37917846a1
– Panda
I could solve by making some adaptations in the code, but now I wanted to pass a date parameter to have a filter. You tell me how I can do this?
– G. J