Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#812965
If Crystal Reports is installed on the same server as your ProcessMaker server, you can use the exec(), system() or passthru() functions in PHP to generate a report in Crystal Reports from the command line. See:
https://www.rklesolutions.com/blog/usin ... mand-line/
https://archive.sap.com/discussions/thread/965318

For example:
Code: Select all
$username = 'johndoe';
$password = 'pAsSw0rD';
$sqlServer = 'acmeSql';
$cmd = "C:\path\crexport.exe -F \"C:\path\CustList.rpt\" -U \"$username\" -P \"$password\" -S\"$sqlServer\" -D\"clientdb\" -O \"C:CustList.pdf\" -Epdf -XFile -N1";
exec($cmd);
If Crystal Reports is installed on another computer, then you will need to login to the other computer with ssh_connect() and execute the command. For example:
Code: Select all
$username = 'johndoe';
$password = 'pAsSw0rD';
$sqlServer = 'acmeSql';
$cmd = "C:\path\crexport.exe -F \"C:\path\CustList.rpt\" -U \"$username\" -P \"$password\" -S\"$sqlServer\" -D\"clientdb\" -O \"C:CustList.pdf\" -Epdf -XFile -N1";
$connection = ssh2_connect('crystal_machine.example.com', 22);
ssh2_auth_password($connection, $username, $password);
$stream = ssh2_exec($connection, $cmd);
#812976
If Crystal Reports is installed on another computer, you can use this code to copy the file from your Crystal Reports server to the Public Files of a process on your ProcessMaker server. For example:
Code: Select all
$username = 'johndoe';
$password = 'pAsSw0rD';
$sqlServer = 'acmeSql';
$cmd = "C:\path\crexport.exe -F \"C:\path\CustList.rpt\" -U \"$username\" -P \"$password\" -S\"$sqlServer\" -D\"clientdb\" -O \"C:CustList.pdf\" -Epdf -XFile -N1";
$connection = ssh2_connect('crystal_machine.example.com', 22);
ssh2_auth_password($connection, $username, $password);
$stream = ssh2_exec($connection, $cmd);
ssh2_scp_recv($connection, 'C:\CustList.pdf', '/opt/processmaker/shared/sites/workflow/public/3713073734d824385011f94010814136/customerList.pdf');
@@reportUrl = "http://example.com/sysworkflow/en/neoclassic/3713073734d824385011f94010814136/customerList.pdf";
Where "reportUrl" is the variable for a hidden field.

If you copy the file to the Public Files for a process, then then you can display the PDF inside a panel control inside a Dynaform with <embed> or <iframe>:
<embed src="http://example.com/sysworkflow/en/neocl ... erList.pdf" width="800px" height="2100px" />
or:
<iframe src="http://example.com/sysworkflow/en/neocl ... erList.pdf" style="width: 100%;height: 100%;border: none;"></iframe>

To open in a new tab/window, use this javascript code in your DynaForm:
Code: Select all
$("#openReport").find("button").click(function() {
   var url = $("#reportUrl").getValue();
   window.open(url, '_blank');
});
Where "openReport" is the ID of a button and "reportUrl" is the ID of a hidden field which holds the URL.
#813137
Dear Amos,
Firstly thank you very much for the comprehensive answer. After struggling a few days to install the correct software components (Crystal Report Runtime, MsSQL and MySQL connection setups) I succeed in generating the report and viewing from ProcessMaker using your directives.
A few points to note for the community:
1 - I couldn't find crexport.exe in default installation of Crystal Reports. Instead I used a helpful project from github: Crystal Report Ninja https://github.com/mhertzfeld/CrystalReportsNinja This helped me a lot, both on installation and testing the report from command line during the development.
2 - My test environment was on Bitnami installation. To access the generated report files, I needed to create case folders before generating the file. So I added a few lines to your code sample:
Code: Select all
$appuid = @@APPLICATION;
$mkdir =  "mkdir C:\Bitnami\processmaker\apps\processmaker\htdocs\shared\sites\workflow\public\\".$appuid;
exec($mkdir);
ProcessMakers embedded printout designers capabilities are limited. Using Crystal Reports, one can build complex reports with crosstabs, graphics, etc. Hope this helps.
What's SAP FICO?

Trustworthy and skill-building, each of these actu[…]

To convert MBOX to PST, start by downloading and i[…]

My Assignment Services stands out as one of the be[…]

Erectile Dysfunction, commonly known as impotence,[…]