| View previous topic :: View next topic |
| Author |
Message |
giustin Newbie
Joined: 05 Jan 2010 Posts: 9
|
Posted: Mon Jan 25, 2010 10:37 am Post subject: Integrate .jrxml with PHP with more parameters |
|
|
Hi,
In PHPJasperXML wiki you told about the parameter to integrate the jrxml report with the php script. I want to know if is possible to use more than one parameter, and how to do that?
Thank you. |
|
| Back to top |
|
 |
ks Site Admin
Joined: 01 Dec 2007 Posts: 295
|
Posted: Mon Jan 25, 2010 12:30 pm Post subject: |
|
|
use array, like
array("para1"=>1,"para2"=>"value2",...); |
|
| Back to top |
|
 |
giustin Newbie
Joined: 05 Jan 2010 Posts: 9
|
|
| Back to top |
|
 |
ks Site Admin
Joined: 01 Dec 2007 Posts: 295
|
|
| Back to top |
|
 |
fernandocchaves Newbie
Joined: 09 Mar 2010 Posts: 10
|
Posted: Tue Mar 09, 2010 4:31 pm Post subject: |
|
|
hi,
i use your class for ireports and i don't know where i'm missing for list the params
i need your help
thanks
############################################################################################
error params PHPJasperXML
line code:
$PHPJasperXML->arrayParameter = array("data_inicial"=>"2010-01-01", "data_final"=>"2010-12-31");
SQL:
SELECT
relatorio.rel_descricao,
date_format(relatorio.rel_data, "%d/%m/%Y") as rel_data,
relatorio.sol_codigo,
associacao.ass_descricao,
departamento.dep_descricao,
unidade.uni_descricao
FROM relatorio
JOIN associacao ON relatorio.ass_codigo = associacao.ass_codigo
JOIN departamento ON relatorio.dep_codigo = departamento.dep_codigo
JOIN unidade ON relatorio.uni_codigo = unidade.uni_codigo
WHERE relatorio.dep_codigo=1 AND rel_data BETWEEN $P{data_inicial} AND $P{data_final}
Warning: Invalid argument supplied for foreach() in /var/www/ireports/class/PHPJasperXML.inc on line 746
Warning: Cannot modify header information - headers already sent by (output started at /var/www/ireports/class/PHPJasperXML.inc:746) in /var/www/ireports/class/fpdf/fpdf.php on line 1019
FPDF error: Some data has already been output to browser, can't send PDF file |
|
| Back to top |
|
 |
ks Site Admin
Joined: 01 Dec 2007 Posts: 295
|
Posted: Tue Mar 09, 2010 11:18 pm Post subject: |
|
|
have you define 2 parameter in jrxml?
Anyway, the sql should look like this
.... AND rel_data BETWEEN '$P{data_inicial}' AND '$P{data_final}' |
|
| Back to top |
|
 |
fernandocchaves Newbie
Joined: 09 Mar 2010 Posts: 10
|
Posted: Wed Mar 10, 2010 11:11 am Post subject: |
|
|
yes i define the parameters in jrxml
your alteration in parameters in slq return errors
AND rel_data BETWEEN '$P{data_inicial}' AND '$P{data_final}'
Error: SQL problems: Parameter index out of range (1 > number of parameters, which is 0) |
|
| Back to top |
|
 |
ks Site Admin
Joined: 01 Dec 2007 Posts: 295
|
Posted: Wed Mar 10, 2010 11:16 am Post subject: |
|
|
| it should work well when preview from webserver. |
|
| Back to top |
|
 |
fernandocchaves Newbie
Joined: 09 Mar 2010 Posts: 10
|
Posted: Wed Mar 10, 2010 6:13 pm Post subject: |
|
|
the error occurred because not return results for the query
solution
method detail changed
public function detail()
{$field_pos_y=$this->arraydetail[0][y_axis]; $biggestY=0; $checkpoint=$this->arraydetail[0][y_axis]; $tempY=$this->arraydetail[0][y_axis];
if($this->arraysqltable){
foreach($this->arraysqltable as $row)
{
if(isset($this->arraygroup)&&($this->global_pointer>0)&&($this->arraysqltable["$this->global_pointer"]["$this->group_pointer"]!=$this->arraysqltable["$this->global_pointer"-1]["$this->group_pointer"])) //check the group's groupExpression existed and same or not
{
$this->pageFooter();
$this->pdf->AddPage();
$this->background();
$this->pageHeader();
$checkpoint=$this->arraydetail[0][y_axis];
$biggestY = 0;
$tempY=$this->arraydetail[0][y_axis];
}
foreach($this->arraydetail as $compare) //this loop is to count possible biggest Y of the coming row
{
switch($compare[hidden_type])
{
case "field":
$txt=$this->analyse_expression($row["$compare[txt]"]);
if(isset($this->arraygroup["$this->group_name"][groupFooter])&&(($checkpoint+($compare[height]*$txt))>($this->arrayPageSetting[pageHeight]-$this->arraygroup["$this->group_name"][groupFooter][0][height]-$this->arrayPageSetting[bottomMargin])))//check group footer existed or not
{
$this->pageFooter();
$this->pdf->AddPage();
$this->background();
$this->pageHeader();
$checkpoint=$this->arraydetail[0][y_axis];
$biggestY=0;
$tempY=$this->arraydetail[0][y_axis];
}
elseif(isset($this->arraypageFooter)&&(($checkpoint+($compare[height]*($this->NbLines($compare[width],$txt))))>($this->arrayPageSetting[pageHeight]-$this->arraypageFooter[0][height]-$this->arrayPageSetting[bottomMargin])))//check pagefooter existed or not
{
$this->pageFooter();
$this->pdf->AddPage();
$this->background();
$headerY = $this->arrayPageSetting[topMargin]+$this->arraypageHeader[0][height];
$this->pageHeader();
$checkpoint=$this->arraydetail[0][y_axis];
$biggestY=0;
$tempY=$this->arraydetail[0][y_axis];
}
elseif(isset($this->arraylastPageFooter)&&(($checkpoint+($compare[height]*($this->NbLines($compare[width],$txt))))>($this->arrayPageSetting[pageHeight]-$this->arraylastPageFooter[0][height]-$this->arrayPageSetting[bottomMargin])))//check lastpagefooter existed or not
{
$this->lastPageFooter();
$this->pdf->AddPage();
$this->background();
$this->pageHeader();
$checkpoint=$this->arraydetail[0][y_axis];
$biggestY=0; $tempY=$this->arraydetail[0][y_axis];
}
if(($checkpoint+($compare[height]*($this->NbLines($compare[width],$txt))))>$tempY)
{$tempY=$checkpoint+($compare[height]*($this->NbLines($compare[width],$txt)));}
break;
case "relativebottomline":
break;
case "report_count":
$this->report_count++;
break;
default:
$this->display($compare,$checkpoint);
break;
}
}
if($checkpoint+$this->arraydetail[0][height]>($this->arrayPageSetting[pageHeight]-$this->arraypageFooter[0][height]-$this->arrayPageSetting[bottomMargin])) //check the upcoming band is greater than footer position or not
{$this->pageFooter();
$this->pdf->AddPage();
$this->background();
$headerY = $this->arrayPageSetting[topMargin]+$this->arraypageHeader[0][height];
$this->pageHeader();
$checkpoint=$this->arraydetail[0][y_axis];
$biggestY=0; $tempY=$this->arraydetail[0][y_axis];}
foreach ($this->arraydetail as $out)
{
switch ($out[hidden_type])
{
case "field":
$this->prepare_print_array=array("type"=>"MultiCell","width"=>$out[width],"height"=>$out[height],"txt"=>$out[txt],"border"=>$out[border],"align"=>$out[align],"fill"=>$out[fill],"hidden_type"=>$out[hidden_type],"printWhenExpression"=>$out[printWhenExpression],"soverflow"=>$out[soverflow],"poverflow"=>$out[poverflow],"link"=>$out[link],"pattern"=>$out[pattern]);
$this->display($this->prepare_print_array,0,true);
if($this->pdf->GetY() > $biggestY)
{$biggestY = $this->pdf->GetY();}
break;
case "relativebottomline":
//$this->relativebottomline($out,$tempY);
$this->relativebottomline($out,$biggestY);
break;
default:
$this->display($out,$checkpoint);
//$checkpoint=$this->pdf->GetY();
break;
}
}
$this->pdf->SetY($biggestY);
if($biggestY>$checkpoint+$this->arraydetail[0][height])
{$checkpoint=$biggestY;}
elseif($biggestY<checkpoint>arraydetail[0][height])
{$checkpoint=$checkpoint+$this->arraydetail[0][height];}
else{$checkpoint=$biggestY;}
//if(isset($this->arraygroup)){$this->global_pointer++;}
$this->global_pointer++;
}
}else{
echo utf8_decode("Not results query");
exit(0);
}
$this->global_pointer--;
if(isset($this->arraylastPageFooter))
{$this->lastPageFooter();}
else{$this->pageFooter();}
} |
|
| Back to top |
|
 |
ks Site Admin
Joined: 01 Dec 2007 Posts: 295
|
Posted: Wed Mar 10, 2010 7:52 pm Post subject: |
|
|
| Thanks for your contribution, however when no result return from sql it didn't display an empty pdf page? |
|
| Back to top |
|
 |
fernandocchaves Newbie
Joined: 09 Mar 2010 Posts: 10
|
Posted: Wed Mar 10, 2010 8:02 pm Post subject: |
|
|
does not create a blank page because it shows the fixed fields
at least it happened to me |
|
| Back to top |
|
 |
fernandocchaves Newbie
Joined: 09 Mar 2010 Posts: 10
|
Posted: Wed Mar 10, 2010 8:09 pm Post subject: |
|
|
I changed many things in their original class as:
font en-us,
group in new or same page,
dynamic SQL,
and this change with a null result.
if you want to check I will send by emai |
|
| Back to top |
|
 |
ks Site Admin
Joined: 01 Dec 2007 Posts: 295
|
Posted: Thu Mar 11, 2010 1:37 am Post subject: |
|
|
| sure, it great to have a copy of your code for backup purpose. Especially group in same page, it is a features request by somebody in this forum. |
|
| Back to top |
|
 |
fernandocchaves Newbie
Joined: 09 Mar 2010 Posts: 10
|
Posted: Thu Mar 11, 2010 11:06 am Post subject: |
|
|
| i send for you |
|
| Back to top |
|
 |
ks Site Admin
Joined: 01 Dec 2007 Posts: 295
|
Posted: Fri Mar 12, 2010 3:57 pm Post subject: |
|
|
hi fernandocchaves,
Currently I found you have update quite a lot of code.Can I use your code as version 0.7a? I like the group in same page function so much! . However seems like there is quite a lot of thing need to do in so that we can have working header, footer and sub total calculation.
Have you done it? Any special step to achieve under your modified version?
Regards,
Ks |
|
| Back to top |
|
 |
|