This topic is locked
[SOLVED]

 Jaspersoft and Phprunner ?

1/31/2014 11:48:54 PM
PHPRunner General questions
A
Abhijeet author

Hello PhpRunner Users !
I want to use jasper reports along with phprunner version 5.3 onwards to 7, Has anybody ever tried it ?
I have a simple question

  1. Whether Jasper report can be run from phprunner
  2. whether I can run the jasper report with the same column security as provided in phprunner for column level security and pass value of column security to it.
    If yes, any simple code to pass value will really help me now, as my projects are stuck up just because of report and column security.
    Please help and thank you for your time in advance.

fhumanes 2/2/2014

Connecting to Jasper Server through webservices interface.
Examples:
report.php:
<?php

if (isset($_REQUEST['rep'])){

if ($_REQUEST['rep']=='1'){

$listado='prueba6_1_1_1';

}

if ($_REQUEST['rep']==2){

$listado='AuditoriaABAP2_1';

}

if ($_REQUEST['rep']==3){

$listado='AuditoriaABAP2_1_1';

}

}

require_once('GenerateReport.php');

$client = new GenerateReport();

$report_unit = $listado;

$report_path = "/reports/Nexus/";

$report_format = "PDF";

$report_params=$_REQUEST;

$result = $client->printReport($report_path,$report_unit, $report_format,$report_params);

header('Content-Type: application/pdf');

echo $result;

?>
GenerateReport.php:
<?php

class GenerateReport {
//Properties

private $_wsdlURL;

private $_username;

private $_password;

private $_soapClient;

private $_imageFolder;

private $_reportPath;

private $_reportName;

private $_outputFormat;

private $_parameterArray;
//Constructor

public function construct() {

// $config = parse_ini_file('config.ini',true);

// $this->_wsdlURL = str_replace("\\", "/", dirname(
FILE)) . '/' . $config['Jasper']['wsdlURL'];

// $this->_username = $config['Jasper']['username'];

// $this->_password = $config['Jasper']['password'];

// $this->_imageFolder = str_replace("\\", "/", dirname(dirname(
FILE))) . '/public/images/';

$this->_wsdlURL = "http://10.82.0.51:8080/jasperserver/services/repository";;

$this->_username = "jasperadmin";

$this->_password = "jasperadmin";

$this->_imageFolder = "c:/temporal";

try {

// $this->_soapClient = new SOAPClient($this->_wsdlURL, array('login' => $this->_username,'password' => $this->_password,'trace' => 1,));

$this->_soapClient = new SoapClient(null, array(

'location' => $this->_wsdlURL,

'uri' => 'urn:',

'login' => $this->_username,

'password' => $this->_password,

'trace' => 1,

'exception'=> 1,

'soap_version' => SOAP_1_1,

'style' => SOAP_RPC,

'use' => SOAP_LITERAL
));

}

catch (Exception $e) {

throw $e;

}

}
//Methods

public function printReport($reportPath, $reportName, $outputFormat = "HTML", $parameterArray = "") {

$this->_reportPath = $reportPath;

$this->_reportName = $reportName;

$this->_outputFormat = $outputFormat;

$this->_parameterArray = $parameterArray;
$requestXML = "<request operationName=\"runReport\">";

$requestXML .= "<argument name=\"RUN_OUTPUT_FORMAT\">$outputFormat</argument>";

$requestXML .= "<resourceDescriptor name=\"\" wsType=\"reportUnit\" uriString=\"$reportPath$reportName\" isNew=\"false\">";

$requestXML .= "<label></label>";

foreach ($parameterArray as $key=>$value) {

$requestXML .= "<parameter name=\"$key\"><![CDATA[$value]]></parameter>";

}

$requestXML .= "</resourceDescriptor></request>";

$params = array("request" => $requestXML );
$reportOutput = "";

try {

$response = $this->_soapClient->runReport($requestXML);

$reportOutput = $this->parseResponseWithReportData(

$this->_soapClient->__getLastResponseHeaders(),

$this->_soapClient->
getLastResponse(),

$outputFormat

);

}//end of try

catch (SoapFault $e) {

if ($e->faultstring == 'looks like we got no XML document') {

$reportOutput = $this->parseResponseWithReportData(

$this->_soapClient->__getLastResponseHeaders(),

$this->_soapClient->__getLastResponse(),

$outputFormat

);

}//end of if

else {

throw new Exception("Error Creating Report " . $e->faultstring);

}//end of else

}//end of catch

return $reportOutput;

}//end of function
private function parseResponseWithReportData($responseHeaders, $response, $outputFormat) {

preg_match('/boundary="(.*?)"/', $responseHeaders, $matches);

$boundary = $matches[1];

$parts = explode($boundary, $response);

$reportOutput = "";

switch ($outputFormat) {

case 'HTML':

foreach($parts as $part) {

if (strpos($part, "Content-Type: image/png") !== false) {

$start = strpos($part, "<") + 1;

$length = (strpos($part, ">") - $start);

$filename = substr($part, $start, $length) . '.png';

$file = fopen("$this->_imageFolder$filename","wb");

$contentStart = strpos($part, "PNG") - 1;

$contentLength = (strpos($part, "--") - $contentStart) + 1;

$contents = substr($part, $contentStart, $contentLength);

fwrite($file, $contents);

fclose($file);

}

if (strpos($part, "Content-Type: image/gif") !== false) {

$start = strpos($part, "<") + 1;

$length = (strpos($part, ">") - $start);

$filename = substr($part, $start, $length) . '.gif';

$file = fopen("$this->_imageFolder$filename","wb");

$contentStart = strpos($part, "GIF");

$contentLength = (strpos($part, "--") - $contentStart) + 1;

$contents = substr($part, $contentStart, $contentLength);

fwrite($file, $contents);

fclose($file);

}

if (strpos($part, "Content-Type: text/html") !== false) {

$contentStart = strpos($part, '<html>');

$contentLength = (strpos($part, '</html>') - $contentStart) + 7;

$reportOutput = substr($part, $contentStart, $contentLength);

}

}//end of for each

break;

case 'PDF':

foreach($parts as $part) {

if (strpos($part, "Content-Type: application/pdf") !== false) {

$reportOutput = substr($part, strpos($part, '%PDF-'));

break;

}

} //end of foreach

break;

case 'RTF':

foreach($parts as $part) {

if (strpos($part, "Content-Type: application/rtf") !== false) {

$reportOutput = substr($part, (strpos($part, 'Content-Id: <report>')+24));

break;

}

}

break;

case 'XLS':

foreach($parts as $part) {

if (strpos($part, "Content-Type: application/xls") !== false) {

$reportOutput = substr($part, (strpos($part, 'Content-Id: <report>') + 24));

break;

}

}

break;
case 'XLSX':

foreach($parts as $part) {

if (strpos($part, "Content-Type: application/xls") !== false) {

$reportOutput = substr($part, (strpos($part, 'Content-Id: <report>') + 24));

break;

}

}

break;
case 'CSV':

foreach($parts as $part) {

if (strpos($part, "Content-Type: application/vnd.ms-excel") !== false) {

$contentStart = strpos($part, 'Content-Id: <report>') + 24;

$reportOutput = substr($part, $contentStart);

break;

}

}

break;

}

return $reportOutput;

}//end of functoin

}//end of class

A
Abul 2/2/2014



Connecting to Jasper Server through webservices interface.
Examples:
report.php:
<?php

if (isset($_REQUEST['rep'])){

if ($_REQUEST['rep']=='1'){

$listado='prueba6_1_1_1';

}

if ($_REQUEST['rep']==2){

$listado='AuditoriaABAP2_1';

}

if ($_REQUEST['rep']==3){

$listado='AuditoriaABAP2_1_1';

}

}

require_once('GenerateReport.php');

$client = new GenerateReport();

$report_unit = $listado;

$report_path = "/reports/Nexus/";

$report_format = "PDF";

$report_params=$_REQUEST;

$result = $client->printReport($report_path,$report_unit, $report_format,$report_params);

header('Content-Type: application/pdf');

echo $result;

?>
GenerateReport.php:
<?php

class GenerateReport {
//Properties

private $_wsdlURL;

private $_username;

private $_password;

private $_soapClient;

private $_imageFolder;

private $_reportPath;

private $_reportName;

private $_outputFormat;

private $_parameterArray;
//Constructor

public function construct() {

// $config = parse_ini_file('config.ini',true);

// $this->_wsdlURL = str_replace("\\", "/", dirname(
FILE)) . '/' . $config['Jasper']['wsdlURL'];

// $this->_username = $config['Jasper']['username'];

// $this->_password = $config['Jasper']['password'];

// $this->_imageFolder = str_replace("\\", "/", dirname(dirname(
FILE))) . '/public/images/';

$this->_wsdlURL = "http://10.82.0.51:8080/jasperserver/services/repository";;

$this->_username = "jasperadmin";

$this->_password = "jasperadmin";

$this->_imageFolder = "c:/temporal";

try {

// $this->_soapClient = new SOAPClient($this->_wsdlURL, array('login' => $this->_username,'password' => $this->_password,'trace' => 1,));

$this->_soapClient = new SoapClient(null, array(

'location' => $this->_wsdlURL,

'uri' => 'urn:',

'login' => $this->_username,

'password' => $this->_password,

'trace' => 1,

'exception'=> 1,

'soap_version' => SOAP_1_1,

'style' => SOAP_RPC,

'use' => SOAP_LITERAL
));

}

catch (Exception $e) {

throw $e;

}

}
//Methods

public function printReport($reportPath, $reportName, $outputFormat = "HTML", $parameterArray = "") {

$this->_reportPath = $reportPath;

$this->_reportName = $reportName;

$this->_outputFormat = $outputFormat;

$this->_parameterArray = $parameterArray;
$requestXML = "<request operationName=\"runReport\">";

$requestXML .= "<argument name=\"RUN_OUTPUT_FORMAT\">$outputFormat</argument>";

$requestXML .= "<resourceDescriptor name=\"\" wsType=\"reportUnit\" uriString=\"$reportPath$reportName\" isNew=\"false\">";

$requestXML .= "<label></label>";

foreach ($parameterArray as $key=>$value) {

$requestXML .= "<parameter name=\"$key\"><![CDATA[$value]]></parameter>";

}

$requestXML .= "</resourceDescriptor></request>";

$params = array("request" => $requestXML );
$reportOutput = "";

try {

$response = $this->_soapClient->runReport($requestXML);

$reportOutput = $this->parseResponseWithReportData(

$this->_soapClient->__getLastResponseHeaders(),

$this->_soapClient->
getLastResponse(),

$outputFormat

);

}//end of try

catch (SoapFault $e) {

if ($e->faultstring == 'looks like we got no XML document') {

$reportOutput = $this->parseResponseWithReportData(

$this->_soapClient->__getLastResponseHeaders(),

$this->_soapClient->__getLastResponse(),

$outputFormat

);

}//end of if

else {

throw new Exception("Error Creating Report " . $e->faultstring);

}//end of else

}//end of catch

return $reportOutput;

}//end of function
private function parseResponseWithReportData($responseHeaders, $response, $outputFormat) {

preg_match('/boundary="(.*?)"/', $responseHeaders, $matches);

$boundary = $matches[1];

$parts = explode($boundary, $response);

$reportOutput = "";

switch ($outputFormat) {

case 'HTML':

foreach($parts as $part) {

if (strpos($part, "Content-Type: image/png") !== false) {

$start = strpos($part, "<") + 1;

$length = (strpos($part, ">") - $start);

$filename = substr($part, $start, $length) . '.png';

$file = fopen("$this->_imageFolder$filename","wb");

$contentStart = strpos($part, "PNG") - 1;

$contentLength = (strpos($part, "--") - $contentStart) + 1;

$contents = substr($part, $contentStart, $contentLength);

fwrite($file, $contents);

fclose($file);

}

if (strpos($part, "Content-Type: image/gif") !== false) {

$start = strpos($part, "<") + 1;

$length = (strpos($part, ">") - $start);

$filename = substr($part, $start, $length) . '.gif';

$file = fopen("$this->_imageFolder$filename","wb");

$contentStart = strpos($part, "GIF");

$contentLength = (strpos($part, "--") - $contentStart) + 1;

$contents = substr($part, $contentStart, $contentLength);

fwrite($file, $contents);

fclose($file);

}

if (strpos($part, "Content-Type: text/html") !== false) {

$contentStart = strpos($part, '<html>');

$contentLength = (strpos($part, '</html>') - $contentStart) + 7;

$reportOutput = substr($part, $contentStart, $contentLength);

}

}//end of for each

break;

case 'PDF':

foreach($parts as $part) {

if (strpos($part, "Content-Type: application/pdf") !== false) {

$reportOutput = substr($part, strpos($part, '%PDF-'));

break;

}

} //end of foreach

break;

case 'RTF':

foreach($parts as $part) {

if (strpos($part, "Content-Type: application/rtf") !== false) {

$reportOutput = substr($part, (strpos($part, 'Content-Id: <report>')+24));

break;

}

}

break;

case 'XLS':

foreach($parts as $part) {

if (strpos($part, "Content-Type: application/xls") !== false) {

$reportOutput = substr($part, (strpos($part, 'Content-Id: <report>') + 24));

break;

}

}

break;
case 'XLSX':

foreach($parts as $part) {

if (strpos($part, "Content-Type: application/xls") !== false) {

$reportOutput = substr($part, (strpos($part, 'Content-Id: <report>') + 24));

break;

}

}

break;
case 'CSV':

foreach($parts as $part) {

if (strpos($part, "Content-Type: application/vnd.ms-excel") !== false) {

$contentStart = strpos($part, 'Content-Id: <report>') + 24;

$reportOutput = substr($part, $contentStart);

break;

}

}

break;

}

return $reportOutput;

}//end of functoin

}//end of class


Jasper report is not working in phprunner project with encrypted fields. The encryption/decryption method used in phprunner does not work in Jasper report I saw. May be some one can provide good solution.

HJB 2/2/2014

http://demo.asprunner.net/volinrok_yahoo_com/Version71Demo/products_list.php - CHARTS / REPORTS AS DETAILS <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=73899&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />
... with all due respect to the jaspering open source folks ..., the very best "2-in-1" charts / reporting web shampoo maker, namely PHPR v7.1, is said to get its 1st final release on 4th/5th instant. Just my 2 cents on the issue.

A
Abhijeet author 2/2/2014



http://demo.asprunner.net/volinrok_yahoo_com/Version71Demo/products_list.php - CHARTS / REPORTS AS DETAILS <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=73900&image=1&table=forumreplies' class='bbc_emoticon' alt=':rolleyes:' />
... with all due respect to the jaspering open source folks ..., the very best "2-in-1" charts / reporting web shampoo maker, namely PHPR v7.1, is said to get its 1st final release on 4th/5th instant. Just my 2 cents on the issue.


I think walk2fly has made a good attempt to demonstrate the reporting capability of phprunner. I do agree that phprunner was a good tool and is still a good tool, but there are certain limitations like for example in report writing we cannot stretch the reporting tool beyond a particular limit, like for example if I want a invoice report or cash voucher report or admission form report with images and all, which is a form like master detail, or maybe master detail/detail reports. is difficult to make, can you give an example of such reports ? Correct me if I am wrong. I have not seen any form like reports in phprunner which is a must and a part of basic reporting tool, I am not able to move the fields to whichever position I want on the report to make it look form like, chart, group, and matrix report comes next (which is already available, but form like report is not).
Thanks fhumanes, I will give your code a try, I am a noob in java, but I will give it a try.

HJB 2/3/2014

Abhijeet, as of v7.1 "customizable template" is offered as an option where one can place any wished field content under the VISUAL EDITOR section in that very shape you/your client finally wants to see it or in other words, in regard to yours "I am not able to move the fields to whichever position I want on the report to make it look form like" I must say that you are definitely wrong here on that issue.

A
Abhijeet author 2/3/2014



Abhijeet, as of v7.1 "customizable template" is offered as an option where one can place any wished field content under the VISUAL EDITOR section in that very shape you/your client finally wants to see it or in other words, in regard to yours "I am not able to move the fields to whichever position I want on the report to make it look form like" I must say that you are definitely wrong here on that issue.


Thanks walk2fly for your time at first instance. Well I have not yet tried 7.1, I will give it a try. One thing, please let me know by "VISUAL EDITOR" do you mean the input i.e list or view page or the report output page.
Thank you.

HJB 2/3/2014

Abhijeet, sequel to NEW built-in v7.1 features in regard to (among others) charts/reports under master/detail, we really talk in fact about "report output page" here rather than so far seen LIST/VIEW standards, say, you are getting TWO different "report design" options here, 1st, the "online shape" one (by cistomizable HTML template) and 2nd the "printed matter" shaped one, each of which which can be individually designed as you like. Rather than to promote that new PHPR v7.1 features are that very remedy to cure any client, you need to weigh things here under "best compromise" here because any "third party" enhancement means, seeing it from the administration point of a project, wearing programmer's glasses, that you are about to play a "jump and run", so, while I'm sure that your "individual form design needs" are 100% covered here or in other words, in regard to "best compromise" I would advise to stay with only ONE design and code generation tool on a project, provided it is covering all your needs, simply because it can save you a lot of time on your project development and maintenance issues later on. Finally, since you raised the keyword "encryption" of fields, I think, you are much better off to start from this point of view in 1st instance when looking at the other things like form design and else while I'm sure, the v7.1 shall cover all your needs properly, giving you a "peace of mind" like atmosphere later on.

A
Abhijeet author 2/3/2014



Abhijeet, sequel to NEW built-in v7.1 features in regard to (among others) charts/reports under master/detail, we really talk in fact about "report output page" here rather than so far seen LIST/VIEW standards, say, you are getting TWO different "report design" options here, 1st, the "online shape" one (by cistomizable HTML template) and 2nd the "printed matter" shaped one, each of which which can be individually designed as you like. Rather than to promote that new PHPR v7.1 features are that very remedy to cure any client, you need to weigh things here under "best compromise" here because any "third party" enhancement means, seeing it from the administration point of a project, wearing programmer's glasses, that you are about to play a "jump and run", so, while I'm sure that your "individual form design needs" are 100% covered here or in other words, in regard to "best compromise" I would advise to stay with only ONE design and code generation tool on a project, provided it is covering all your needs, simply because it can save you a lot of time on your project development and maintenance issues later on. Finally, since you raised the keyword "encryption" of fields, I think, you are much better off to start from this point of view in 1st instance when looking at the other things like form design and else while I'm sure, the v7.1 shall cover all your needs properly, giving you a "peace of mind" like atmosphere later on.


Thanks buddy, I think I should get my hands on 7.1 version then. Thank you for your efforts and time extended.

HJB 2/3/2014

http://asprunner.com/tmp/phprunner-trial-setup.exe - v7.1 preview download with whopping 21 days "peace of mind" period
Abhijeet, well..., see above mentioned things with your own eyes while 1st v7.1 release to happen by tomorrow or the day after tomorrow, or in other words, you shall most probably NOT need to run the 21 days trial period on the preview version at all after fully have been noticing that your particular needs to serve any client on a form like report design are fully covered. Stay tuned ...

A
Abul 2/22/2014



Jasper report is not working in phprunner project with encrypted fields. The encryption/decryption method used in phprunner does not work in Jasper report I saw. May be some one can provide good solution.


I think jasper can handle encryption decryption in phprunner. I just tried for another reporting tools. I think you have to insert your encryption key before the encrypted fields for SQL query in jasper query window .

A
Abhijeet author 3/27/2014

Hi Walk2fly !
Greetings !
Well I have downloaded the 7.1 version as trial version, but nothing has been mentioned about form like report in the changes made or rather revision history. Is it done in this version ?
Thanks and Regards.

Admin 3/27/2014

What is "form like report"? Screenshot please.

A
Abhijeet author 3/28/2014



What is "form like report"? Screenshot please.


Please find attached form like report.


Regards

Admin 3/28/2014

This is not a report but a simple view page with data from both master and details tables on the same screen. This functionality been available in PHPRunner forever.
Take a look at these sample pages:

http://xlinesoft.com/livedemo/invoice/livedemo1/invoices_view.php?hash=26c22e7c53102f4f80fa43d3f68eb6be

http://xlinesoft.com/livedemo/phprunner/livedemo1/orders_view.php?editid1=10253 (details data shown in the tab but it's completely optional)

A
Abhijeet author 3/28/2014

I am confused. Are you showing me the invoice template ? Actually Invoice is just one of the example, it may be cash voucher, or a cash receipt or a admission form, all these things needs to be printed may be with a logo and nice looking features. view page is not always helpful and suitable for printing purposes.
Please elaborate how did you manage to get this invoice report, is it from a invoice template ? And also let me know if the above given examples are also possible to print in that type ? I have the enterprise manager given by you, is it possible to do in that for version 7.1 ?
Your inputs will be really helpful.
Regards.