3

Is it possible to pass a variable from php to a report in JasperReports Server? For example, in my php application I keep the department_id stored in a session variable. I would like to pass the department_id over to my reports running on JasperReports Server and display the information appropriate for that department. in the iReport I have a query like: SELECT * FROM employees WHERE department_id = $P{dept_id_from_php}, but I have to build a dropdown select list to pass the dept_id parameter.

The end result is I would like the user logged into my PHP application to view the employee information that is related to the department the logged-in-user belongs to. I don't want to pass this over using the querystring because the user could just change the id in the querystring and have access to other departments information. Ideally I would like to only pass that parameter once, then reuse it in all the reports, like a global variable.

Is this possible?

Alex K
  • 22,315
  • 19
  • 108
  • 236
Ronedog
  • 2,313
  • 8
  • 43
  • 85
  • Hello Ronedog, I have exactly the same problem as you, have you found a solution for this? or have some clues?, thanks in advance. –  Apr 24 '10 at 16:33
  • I wish...Trying OpenReports now to see what it can do to help me – Ronedog Apr 26 '10 at 23:08
  • I'm finding myself looking for exactly the same functionality. I'm curious how you eventually solved it? – Lee Nov 10 '11 at 19:29
  • See this question for a reflection on the subject: http://stackoverflow.com/questions/8795932/passing-in-content-when-generating-jasperserver-report-using-the-rest-api – MaxH Jan 20 '12 at 14:39

1 Answers1

2

There is a terrific (small) php SOAP interface here https://github.com/adlermedrado/PHP-JasperServer-Integration for this purpose. It should save some time!

//example
//construct report object
$report    =    array("_REPORT_PARAMETER"=>$php_variable);

//valid output PDF, JRPRINT, HTML, XLS, XML, CSV and RTF
$jasper->run('/path/_Standard_Report','PDF',$report,false);

It should be noted that I have not had great success with XLS export, but other formats seem to work very well.

metalgreen
  • 21
  • 2