Nice lookin' reports

Sorry for the delay,…been away.

  1. Delete the pdf-query parameter from your parameter list.
  2. Delete the exclamation mark (!) in your Query window.

jsb

Hey. I am trying to test this. Looks great. However Im having this issue upon clicking the button I get the following message:

Notice: Use of undefined constant xml_file - assumed ‘xml_file’ in C:\Program Files (x86)\NetMake\v7\wwwroot\scriptcase\app\AGSAM\reports\cpv.php on line 6 Fail to connect database

Any help would be much appreciated.

Can you please clarify this step for me I think I may be missing something. I have copied the sql query and pasted it in the button code. Is anything else required? Do I have to also place something in the index.php file?

Ok, here are a few pictures to illustrate (thought it might be beneficial). :slight_smile:

Image1 shows the iReport Designer with the parameter set in the query window.

Image2 is your PHP button code area

Image3 is your function to call the index.php.

And here is the index.php

<?php
session_start();

include_once(‘class/tcpdf/tcpdf.php’);
include_once(“class/PHPJasperXML.inc.php”);

$xml = simplexml_load_file($_SESSION[‘report’][‘xml_file’]); //variable for jrxml file

$PHPJasperXML = new PHPJasperXML();

$PHPJasperXML->arrayParameter=array(‘pdf_query’=>$_SESSION[‘report’][‘pdf_query’]); //variable for sql statement
$PHPJasperXML->xml_dismantle($xml);

$PHPJasperXML->transferDBtoArray($_SESSION[‘report’][‘host’],
$_SESSION[‘report’][‘user’],
$_SESSION[‘report’][‘pass’],
$_SESSION[‘report’][‘db’]);
$PHPJasperXML->outpage(“I”); //page output method I:standard output Download file
?>

Good luck
jsb

ireport.jpg

button.jpg

function.jpg

Thanks for the screenshots. I really appreciate it. I’m still working on this. Now I’m getting this error:

Warning: simplexml_load_file(): I/O warning : failed to load external entity “” in C:\Program Files (x86)\NetMake\v7\wwwroot\scriptcase\app\AGSAM\reports\cpv.php on line 6

Yes and what do you read at line 6 in that file? We have only a cloudy crystal ball and can’t look itself …

Oops I knew I was forgetting something!

$xml = simplexml_load_file($_SESSION[‘reports’][‘xml_file’]); //variable for jrxml file

I had removed this:
include_once(‘class/tcpdf/tcpdf.php’);
from the php file however after placing it back now I get the following error:
Warning: simplexml_load_file(): I/O warning : failed to load external entity “” in C:\Program Files (x86)\NetMake\v7\wwwroot\scriptcase\app\AGSAM\reports\cpv.php on line 7 TCPDF ERROR: Some data has already been output, can’t send PDF file

Line 7 is: $xml = simplexml_load_file($_SESSION[‘report’][‘xml_file’]); //variable for jrxml file

Your $_SESSION[‘report’][‘xml_file’] variable seems to be empty. Check the value of it.

jsb

I’m really new to this. I copied the code as you posted it. Can you please tell me what I have to change. Do I have to replace xml_file with something?

Once again I’m really appreciative of the fact that you guys go out of your way to help out!

Here is my code, all code is exactly how it is posted below except for the query:

PHP FILE located in reports folder in the scriptcase application folder
<?php
session_start();

include_once(‘class/tcpdf/tcpdf.php’);
include_once(“class/PHPJasperXML.inc.php”);

$xml = simplexml_load_file($_SESSION[‘report’][‘xml_file’]); //variable for jrxml file

$PHPJasperXML = new PHPJasperXML();

$PHPJasperXML->arrayParameter=array(‘cpv_query’=>$_SESSION[‘report’][‘cpv_query’]); //variable for sql statement
$PHPJasperXML->xml_dismantle($xml);

$PHPJasperXML->transferDBtoArray($_SESSION[‘report’][‘host’],
$_SESSION[‘report’][‘user’],
$_SESSION[‘report’][‘pass’],
$_SESSION[‘report’][‘db’]);
$PHPJasperXML->outpage(“I”); //page output method I:standard output Download file
?>

My report called cpv.jrxml is also located in the reports folder. It has the following as the query string
${cpv_query}

Button Code
$cpv_query=“SELECT… cash_payments.cpvno={cpvno}”;//sql statement from iReport

$xml_file=“cpv.jrxml”; //filename of report created with iReport

cpv_print($cpv_query,$xml_file);

PHP Method called cpv_print to call the the php file
if(!isset($_SESSION[‘report’]))
{
$_SESSION[‘report’]=array(‘host’=>[sc_glo_servidor],‘user’=>[sc_glo_usuario],‘pass’=>sc_decode([sc_glo_senha]),
‘db’=>[sc_glo_banco],‘cpv_query’=>’’,‘xml_file’=>’’);
}

$_SESSION[‘report’][‘xml_file’]=$xml_file;
$_SESSION[‘report’][‘cpv_query’]=$cpv_query;

sc_redir(…/reports/cpv.php,"","_blank");

Thanks for all the help.

I have finally got it working, for some reason the the file name is not passing so I have entered it in the php file.

Thanks for all the help.

Glad you got it working.
Regarding the file name, there is an error in your PHP method.

Change the line: $_SESSION[‘report’][‘xml_file’]=$xml_file;
To: $_SESSION[‘report’][‘xml_file’]="…/reports/".$xml_file;

jsb

Hi Jsb, thanks again for help.
Unfortunately I’m still struggling with IReport but I had to suspend my testing becouse I’m stucked in another problem.
I’m trying to use sc_mail_send and BBC. I have to send mail to people without showing the other receivers of my mail.
This is the line code.
sc_mail_send([glo_mail_smtp_server], [glo_mail_smtp_user], [glo_mail_smtp_pass], $mail_from , ‘info@name.it’, {subject}, $message, “H”, $email_to , $type_copy , [glo_mail_smtp_port],[glo_mail_smtp_ssl]);
I switched the “To” e-mail variable to “Copies” and on “To” I used a fixed string like info@name.it . $type_copy is “BBC”.
Using two receiver 1 and 2 this is what happens.
On receiver 1 I see exactly what expected : To -> info@name.it and Bbc -> Receiver 1 mail
On receiver 2 I see only to and nothing else: To -> info@name.it

Does it make sense ?? Thanks

@giovannino: PLEASE report other problems in a new thread …

@aducom: please move this post to a new thread.

YES !!! Sorry !!

fatal error with ireports sc_redir !!!

Hi ,

First of all , thanks for your good job concerning Ireports intergration !!!
I have installed and try to integrated a reports but I receive a error message write below, what do I wrong ???
I think it’s with sc_redir command but, I cannot find what is wrong !!!

Thanks in advance for your help
Can

Fatal error: Call to undefined method grid_XXXXX_apl::nmgp_redireciona_form() in
…wwwroot\scriptcase\app\MyProject\grid_XXXXX\grid_XXXXX.php on line 1938

=====================================
BUTTON CODE

$pdf_query=“SELECT
…”;

$xml_file=“report1.jrxml”;
sc_set_global($pdf_query);
sc_set_global($xml_file);

sc_redir(…/ireports/ireports.php);

=======================================
grid_XXXXX.php CODE

if (isset($this->sc_temp_pdf_query)) {$_SESSION[‘pdf_query’] = $this->sc_temp_pdf_query;}
if (isset($this->sc_temp_xml_file)) {$_SESSION[‘xml_file’] = $this->sc_temp_xml_file;}
if (!isset($this->Campos_Mens_erro) || empty($this->Campos_Mens_erro))
{
//////////////////////////////////////// line 1938 /////////////////////

$this->nmgp_redireciona_form("…/ireports/ireports.php", $this->nm_location, “”,"_self", 440, 630, “ret_self”);

//////////////////////////////////////// //////////////////////////////
};
if (isset($this->sc_temp_pdf_query)) {$_SESSION[‘pdf_query’] = $this->sc_temp_pdf_query;}
if (isset($this->sc_temp_xml_file)) {$_SESSION[‘xml_file’] = $this->sc_temp_xml_file;}

=======================================
APP DIRECTORY TREE and filename

…wwwroot\scriptcase\app\MyProject\ireports

in ireports directory :

\class
ireports.php
report1.jrxml

$_SESSION[‘report’][‘xml_file’] is empty ?

Hi,
I’m back… ;-( .
I’ve just re-taken on hand the reporting story…
On following lines I listed what I did and, on the bottom, the error I got after clicking on form button.
With the eco “VALUE XML FILE IS” it seems that $_SESSION[‘report’][‘xml_file’] would be empty.
… I hope to see a report asap
Many thanks

function print_pdf


if(!isset($_SESSION[‘report’]))
{
$_SESSION[‘report’]=array(‘host’=>[sc_glo_servidor],‘user’=>[sc_glo_usuario],‘pass’=>sc_decode([sc_glo_senha]),
‘db’=>[sc_glo_banco],‘pdf_query’=>’’,‘xml_file’=>’’);
}

$_SESSION[‘report’][‘xml_file’]= $xml_file ;
$_SESSION[‘report’][‘pdf_query’]= $pdf_query;

sc_redir(…/z_ireport_class/index.php,"","_blank");

Button Settings: jasperbutton


$pdf_query = ‘SELECT * FROM gartes’; //sql statement from iReport
$xml_file=‘gartes.jrxml’; //filename of report created with iReport
sc_set_global($pdf_query);
sc_set_global($xml_file);

print_pdf($pdf_query,$xml_file);

index.php


<?php
session_start();

include_once(‘class/tcpdf/tcpdf.php’);
include_once(‘class/PHPJasperXML.inc.php’);

echo "VALUE XML FILE IS " . $_SESSION[‘report’][‘xml_file’];

$xml = simplexml_load_file($_SESSION[‘report’][‘xml_file’]); //variable for jrxml file

$PHPJasperXML = new PHPJasperXML();

$PHPJasperXML->arrayParameter=array(‘pdf_query’=>$_SESSION[‘report’][‘pdf_query’]); //variable for sql statement
$PHPJasperXML->xml_dismantle($xml);

$PHPJasperXML->transferDBtoArray($_SESSION[‘report’][‘host’],
$_SESSION[‘report’][‘user’],
$_SESSION[‘report’][‘pass’],
$_SESSION[‘report’][‘db’]);
$PHPJasperXML->outpage(“I”); //page output method I:standard output Download file
?>

ERROR SHOWN AFTER CLICKING BUTTON


VALUE XML FILE IS
Notice: Undefined index: …/z_ireport_class/xml_file in C:\Program Files (x86)\Scriptcase\v71\wwwroot\scriptcase\app\c4tm\z_ireport_class\index.php on line 9 Warning: simplexml_load_file(): I/O warning : failed to load external entity “” in C:\Program Files (x86)\Scriptcase\v71\wwwroot\scriptcase\app\c4tm\z_ireport_class\index.php on line 9 TCPDF ERROR: Some data has already been output, can’t send PDF file

Just an idea.
You didn’t declare an argument/parameter for your print_pdf() function, did you?

function rpint_pdf($xml_file)
{

}

jsb

A little bit better but still not result

Hi JSB,

I did a short video to show what’s my problem now.

http://www.youtube.com/watch?v=gDkvs8GXtF4

It seems all correct but still I can get any output.
I’ve tried also to use $P{pdf_query} but it do not works. The only way to produce the report from iReport is to use $P!{pdf_query} with esclamation mark.
I did also a test using $_SESSION[‘report’][‘xml_file’]="…/z_ireport_class/".$xml_file; but nothing change too.

On the SC side I concentrated all the code into button code only
PHP Code


if(!isset($_SESSION[‘report’]))
{
$_SESSION[‘report’]=array(‘host’=>[sc_glo_servidor],‘user’=>[sc_glo_usuario],‘pass’=>sc_decode([sc_glo_senha]),
‘db’=>[sc_glo_banco],‘pdf_query’=>’’,‘xml_file’=>’’);
}

$pdf_query = ‘SELECT * FROM gartes’;
$xml_file=‘gartes.jrxml’;

$_SESSION[‘report’][‘xml_file’]=$xml_file;
$_SESSION[‘report’][‘pdf_query’]=$pdf_query;

sc_redir(…/z_ireport_class/index.php);

and index.php file


<?php
session_start();

include_once(‘class/tcpdf/tcpdf.php’);
include_once(‘class/PHPJasperXML.inc.php’);

echo " VALUE XML FILE IS --> " . $_SESSION[‘report’][‘xml_file’] . ‘<BR>’
. " VALUE OF QUERY IS -> " . $_SESSION[‘report’][‘pdf_query’].’<BR>’
. " VALUE OF USER IS —> " . $_SESSION[‘report’][‘user’].’<BR>’
. " VALUE OF PASSW IS -> " . $_SESSION[‘report’][‘pass’].’<BR>’
. " VALUE OF DB IS ------> " . $_SESSION[‘report’][‘db’].’<BR>’
;

$xml = simplexml_load_file($_SESSION[‘report’][‘xml_file’]); //variable for jrxml file

$PHPJasperXML = new PHPJasperXML();

$PHPJasperXML->debugsql=true;

$PHPJasperXML->arrayParameter=array(‘pdf_query’=>$_SESSION[‘report’][‘pdf_query’]); //variable for sql statement
$PHPJasperXML->xml_dismantle($xml);

$PHPJasperXML->transferDBtoArray($_SESSION[‘report’][‘host’],
$_SESSION[‘report’][‘user’],
$_SESSION[‘report’][‘pass’],
$_SESSION[‘report’][‘db’]);
$PHPJasperXML->outpage(“I”); //page output method I:standard output Download file
?>

Hi,
please remove the exclamation mark (!) from your parameter statement. IT IS ONLY USEFUL WITHIN iREPORT!
It is for prompting you for the value of the parameter when you run it in ireport. TCPDF has absolutely no idea what it is good for.
Also remove your echo-statement, it prevents tcpdf from generating any output. You now know that your data are OK.
Otherwise your stuff looks good. I just created a form with your code and it works as it is supposed to.
May be change $PHPJasperXML->outpage(“I”) to $PHPJasperXML->outpage(“D”) to see if it generates a download.
I have to admit, I’m running out of ideas. :slight_smile:

jsb