Jump to content
We've recently updated our Privacy Statement, available here ×

How to get PHP variable in Ireport


johann60280
Go to solution Solved by johann60280,

Recommended Posts

I just begin to work on Ireport and jasperserver. My wishes is to generate a jasper report in my php application. I work on Symfony2. Actually I generate my report in my application but the problem is in Ireport I didn't get the php variable I send from my php application. And my report is in Jasperserver when I'm done the report modification.

This is my action from my php application:

public function result_recherche_googleAction(){    $em = $this->getDoctrine()->getManager ();    $request = $this->getRequest();    $id_pef = $request->request->get('id_pef');    if ($request->isXmlHttpRequest()) {       $jasperclient=new JasperClient();       $lien=$jasperclient->getUrlManyParams($this->container,"RechercheGoogle",array("id_pef" => $id_pef));           return $this->get('templating')->renderResponse('gideBundle:Edition:res_edition_recherche_google.html.twig',array(        //'trans'=>$pefs,        'lien'=>$lien,        ));    //}     }    else {        //return $this->feuillePEFAction();        return new Response(json_encode($id_pef));    }}[/code]

This is the code from my report:

<?xml version="1.0" encoding="UTF-8"?><jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="RechercheGoogle" language="groovy" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="7e1de1d9-a08e-47ec-8af2-e93dbec288e7">    <property name="ireport.zoom" value="1.0"/>    <property name="ireport.x" value="0"/>    <property name="ireport.y" value="0"/>    <parameter name="id_pef" class="java.lang.Integer"/>    <background>        <band splitType="Stretch"/>    </background>    <title>        <band height="270" splitType="Stretch">            <staticText>                <reportElement x="82" y="34" width="100" height="20" uuid="8969389a-851b-44e5-a88c-14a4b217fc47"/>                <text><![CDATA[Coucou !!!]]></text>            </staticText>            <staticText>                <reportElement x="252" y="21" width="240" height="58" uuid="1bebe360-cabf-485f-a158-befade8ee7a9"/>                <textElement>                    <font size="14"/>                </textElement>                <text><![CDATA[iD du PEF:  $P{id_pef}]]></text>            </staticText>            <textField>                <reportElement x="322" y="125" width="100" height="20" uuid="eae36fce-573e-484c-8cca-e8b4007d5e2b"/>                <textFieldExpression><![CDATA[$P{id_pef}]]></textFieldExpression>            </textField>            <textField>                <reportElement x="224" y="109" width="100" height="20" uuid="2e2db24f-899b-45d0-9434-62cdd0f35171"/>                <textFieldExpression><![CDATA[$P{id_pef}]]></textFieldExpression>            </textField>        </band>    </title>    <pageHeader>        <band height="35" splitType="Stretch"/>    </pageHeader>    <columnHeader>        <band height="61" splitType="Stretch"/>    </columnHeader>    <detail>        <band height="125" splitType="Stretch"/>    </detail>    <columnFooter>        <band height="45" splitType="Stretch"/>    </columnFooter>    <pageFooter>        <band height="54" splitType="Stretch"/>    </pageFooter>    <summary>        <band height="42" splitType="Stretch">            <textField>                <reportElement x="432" y="22" width="100" height="20" uuid="0d41b36b-f441-400c-af62-753fa3cb4b63"/>                <textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>            </textField>        </band>    </summary></jasperReport>[/code]

I hope I'm clear. I try everything and I search a lot but any information about my problem. I hope someone can help me because It's very important! If you want more information about my problem tell me.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

  • Solution

Yes I check the following thread at StackOverflow but it's not the same library I use. But Thank  you for your answer!! Finally I solve my problem!!

In my report in jasperserver I just add an "input control" from Ireport.

In the view of jasperserver in Ireport  I search my report and I add an Input control in directory "Input Control". I just do right click in the directory "Input Control" and I click in "Create a local input control" and after I name my input control like my parameter from Ireport and it's work!!! Now I can send a php variable and I get this variable in my report!! Hope it's help!! :)

 

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...