Php Laravel with Jasper report

Asked

Viewed 2,049 times

4

I’m using the framework, and jasperphp to generate the report, but I can’t pass the pro database, most use mysql to generate the report, only I’m using Mssql, someone give me a light with that please, of the two ways I try to pass the bank the report is not generated.

 $my_where = "where cast(Data_concluido as date) >= $dataInicio AND cast(Data_concluido as date) <= $dataFim AND pes.tipo = $tipo AND pes.Empresa = $empresa" ;

    $my_where = '"' .  $my_where . '"'; 


   $database = [
        'driver' => 'sqlsrv',
        'username' => 'username',            
        'password' => 'password',            
        'jdbc_driver' => 'net.sourceforge.jtds.jdbc.Driver',
        'jdbc_url' => 'jdbc:jtds:sqlserver://localhost/database'
    ];
     $filename = time();

    JasperPHP::process(base_path() . '/app/reports/PesagemEntrada.jasper', 
    base_path() . '/app/reports/PesagemEntrada.jasper' . $filename,
    array("pdf"), //array("pdf", "rtf"), para gerar pdf e word  
    array("my_where" =>  $my_where), 
    $database
    )->execute();

I tried that way too :

 JasperPHP::process(base_path() . '/app/reports/PesagemEntrada.jasper', 
    base_path() . '/app/reports/PesagemEntrada.jasper' . $filename,
    array("pdf"), //array("pdf", "rtf"), para gerar pdf e word  
    array("my_where" =>  $my_where), 
    \Config::get('database.connections.sqlsrv')
    )->execute();

The query of my jrxml:

    <queryString>
    <![CDATA[SELECT                                         
                                pes.Cod_pesagem,
                                pes.Peso_bruto,
                                pes.Peso_tara,
                                pes.Peso_liquido,
                                pes.Peso_rejeito,
                                pes.tipo,                                     
                                CONVERT(nvarchar(30), pes.Databruto, 103) as Databruto,
                                CONVERT(nvarchar(30), pes.Datatara, 103) as Datatara,
                                pes.Placa,              
                                pn.cod_pn,
                                pn.parceiros_negocio,
                                prod.Cod_Produto,
                                prod.Produto,
                                motor.cod_motorista,
                                motor.motorista,
                                emp.cod_empresa,
                                emp.empresa

                                        FROM
                                        PESAGEM pes
                                        INNER JOIN EMPRESA as emp ON (pes.Empresa = emp.cod_empresa)
                                        INNER JOIN PARCEIRO_NEGOCIO pn ON (pes.Cod_PN = pn.cod_pn)
                                        INNER JOIN PRODUTO prod ON (pes.Cod_Produto = prod.Cod_Produto)
                                        INNER JOIN MOTORISTA motor ON (pes.Cod_Motorista = motor.cod_motorista) 
                                        $P!{my_where}]]>
  • Why not create the connection to the bank in jasperserver itself? and in the report you define which connection to use. Oh, I get it. You are assembling the report direct from .jasper. I recommend then searching for jasperserver, which is a service to manage the reports.

  • With jasperserver the database is already saved?

  • Jasperserver is a repository service for reports and datasets. Where you through Jaspersoft studio draws the report, connects on the dataset and ready. When calling by the API only passes the parameters that API returns you the report in the format you want. Search on, this technology is sensational. Forget about manipulating the files. Jasper, this is very old.

  • junior what would be the appropriate api to make this connection?

  • Raphael: community.jaspersoft.com/project/php-client

  • Use this https://github.com/geekcom/phpjasper library, it’s an improved upgrade from another that didn’t work for Laravel 5.1, it was a few friends and I rewrote it.

  • Good afternoon everyone, I am developing a pure PHP project to generate the report in pdf from the file . jrxml , already has a working version on Github https://github.com/QuilhaSoft/JasperPHP

Show 2 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.