PMK Output Documents
PMK Output Documents
Page 1 of 8
Output Documents
From ProcessMaker
Output Documents are files generated while running a case, which are meant to be printed out or stored digitally outside ProcessMaker. Output Documents are useful for creating external records of case data, as well as creating formatted output such as bills, receipts, and letters. They are generated from HTML templates containing references to system and case variables, which are auto-inserted when the Output Document is generated as a step when running a case. Output Documents are generated as PDF (Portable Document Format) and/or DOC (Word document) files, so they can be easily opened and printed using Adobe Acrobat and Microsoft Office (or alternatives such as Foxit Reader, Evince, Okular, WordPerfect, AbiWord and OpenOffice).
Contents
1 Creating Output Documents 2 Editing Output Documents 3 Output Document Example 4 Grids in Output documents 5 Output Document Storage 6 Accessing Output Documents through Triggers
http://wiki.processmaker.com/index.php?title=Output_Documents&printable=yes
24-09-2010
Page 2 of 8
Title: A label to identify the Output Document. Filename generated: The name of the file to be created when the Output Document is generated while running cases. Description: A description about the Output Document, which should inform the user what is the general content or purpose of the document. Orientation: Select whether the document is in a portrait (vertical) or landscape (horizontal) layout. Output Document to Generate: Select whether the Output Document will be generated in DOC, PDF, or BOTH formats. Enable Versioning: Check this option if needing to keep multiple versions of the Output Document. Versioning is a new option in ProcessMaker 1.2-XXXX and later and is useful if creating the same Output Document at multiple steps during a case. Destination Path: Enter an alternative path to save the Output Documents if not using the default storage path inside ProcessMaker. This is a new option in ProcessMaker 1.2-XXXX and later. Tags: Enter identifying tag word(s) to provide more information about the Output Document. This is a new option in ProcessMaker 1.2-XXXX and later.
Case variables and system variables can be inserted into the Output Document:
@#FIELD-NAME inserts the value of the variable without any changes. @@FIELD-NAME inserts the value of the variable enclosed in "" (double quotation marks).
http://wiki.processmaker.com/index.php?title=Output_Documents&printable=yes
24-09-2010
Page 3 of 8
Any quotation marks inside the value will be escaped with backslashes, such as "Don\'t say \"hello\"". When done editing, click Save to save the changes to the Output Document. Unfortunately, the WYSIWYG editor allows for only limited formatting, so it is not possible to insert more advanced types of HTML elements such as hyperlinks, images or tables. The HTML code must be directly edited to insert these sorts of elements. In order to edit the HTML code, open the MySQL database with phpMyAdmin. Go to the CONTENT table in the wf_<WORKSPACE> database (which is probably the default workspace wf_workflow). Find all the templates for Output Documents by clicking on the SQL tab in phpMyAdmin and entering the following query:
SELECT * FROM CONTENT WHERE CON_CATEGORY='OUT_DOC_TEMPLATE'
The HTML code for the Output Document template is located in the CON_VALUE field. Although the HTML code can be edited directly inside phpMyAdmin, it is easier to copy the code and paste it an HTML editor (such as DreamWeaver, FrontPage or KompoZer) where it can easily be altered. When finished editing the code, paste it back into the CON_VALUE field in phpMyAdmin.
http://wiki.processmaker.com/index.php?title=Output_Documents&printable=yes
24-09-2010
Page 4 of 8
close the grid, where GRID-NAME is the name of a grid object in a master DynaForm or an array of associative arrays. This array can be a case variable manually defined in a trigger or returned by querying a database with executeQuery(). Between these tags, include the variables for the fields in that grid:
@>GRID-NAME @#FIELD-1 @#FIELD-2 @#FIELD-3 @<GRID-NAME
The fields enclosed in the opening and closing grid tags will be repeated as many times as there are rows in the grid. For example, if designing a travel expenses report, the following Output Document would list each of the expenses in a grid named "EXPENSE_GRID":
Travel Expense Report @#FIRST_NAME @#LAST_NAME @#REPORT_MONTH Date Type of Expense @>EXPENSE_GRID @#DATE @#TYPE @<EXPENSE_GRID Description @#DESCRIPTION Amount @#AMOUNT
The default font for Output Documents is Arial, which is a variable-width font. It is hard to create neat columns of data with a variable-width font, so it may be useful to either add HTML formatting to use a fixed-width font or to place the grid fields inside an HTML table. In order to directly edit the HTML code, the template will have to be edited inside the MySQL database. Here is an example of the same grid fields inside an HTML table:
<CENTER> Travel Expense Report <BR> @#FIRST_NAME @#LAST_NAME <BR> @#REPORT_MONTH <BR> <BR> <TABLE> <TR> <TH> Date </TH> <TH> Type Of expense </TH> <TH> Description </TH> <TH> Amount </TH> </TR> @>EXPENSE_GRID <TR> <TD> @#DATE </TD> <TD> @#TYPE </TD> <TD> @#DESCRIPTION </TD> <TD> @#AMOUNT </TD> </TR> @<EXPENSE_GRID </TABLE> </CENTER>
Although the EXPENSE_GRID could come from a grid DynaForm, it could also be generated by using executeQuery() to query a PM Table or an external database. If the database has different field names than those in the Output Document, use "AS" to rename the fields. For example, a trigger containing the following code could be fired before the above Output Document is generated:
http://wiki.processmaker.com/index.php?title=Output_Documents&printable=yes
24-09-2010
Page 5 of 8
$db = 'XXXXXXXXXXXXXXXXXXXXXXXXXXX'; //Unique ID for an external database $query = 'SELECT EXP_DATE AS DATE, EXP_TYPE AS TYPE, EXP_DESC AS DESCRIPTION, EXP_AMT AS AMOUNT FROM EXPENSES"; @@EXPENSE_GRID = executeQuery($query, $db);
Likewise, the trigger could manually create @@EXPENSE_GRID as an array of associative arrays:
@@EXPENSE_GRID = array( array('DATE'=>'2010-04-25', 'TYPE'=>'Airfare', 'DESCRIPTION'=>'Flight to Paris', 'AMOUNT'=>1295.35), array('DATE'=>'2010-04-26', 'TYPE'=>'Lodging', 'DESCRIPTION'=>'Sheraton Hotel', 'AMOUNT'=>300.00 ), array('DATE'=>'2010-04-27', 'TYPE'=>'Meals', 'DESCRIPTION'=>'Lunch w/ client', 'AMOUNT'=>104.95 ) );
To see the information about a particular Output Document, search for its unique ID, which can either be found in the field wf_<WORKSPACE>.OUTPUT_DOCUMENT.OUT_DOC_UID or by opening the list of Output Documents inside ProcessMaker 1.2-2838 or later and clicking the UID link for an Output Document. Once the unique ID is known, it can be used in a SQL query:
select * from CONTENT where CON_ID = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
For example, here is an Output Document defined in both English and Spanish:
mysql> select * from CONTENT where CON_ID = '2136030664a9bfeb8a775d7029704021'; +---------------------+----------------------------------+----------+-------------------------------------------| CON_CATEGORY | CON_ID | CON_LANG | CON_VALUE +---------------------+----------------------------------+----------+-------------------------------------------| OUT_DOC_TEMPLATE | 2136030664a9bfeb8a775d7029704021 | en | Dear @#ClientName,<br>Please open case @#Ca | OUT_DOC_TITLE | 2136030664a9bfeb8a775d7029704021 | en | Open Case Letter | OUT_DOC_DESCRIPTION | 2136030664a9bfeb8a775d7029704021 | en | Letter asking client to open the case | OUT_DOC_FILENAME | 2136030664a9bfeb8a775d7029704021 | en | OpenCaseLetter | OUT_DOC_TEMPLATE | 2136030664a9bfeb8a775d7029704021 | es | Estimado @#ClientName,<br>Por favor abra ca | OUT_DOC_TITLE | 2136030664a9bfeb8a775d7029704021 | es | Carta - Abrir Caso | OUT_DOC_DESCRIPTION | 2136030664a9bfeb8a775d7029704021 | es | Carta pidiendo que el cliente abra el caso | OUT_DOC_FILENAME | 2136030664a9bfeb8a775d7029704021 | es | CartaAbrirCaso +---------------------+----------------------------------+----------+--------------------------------------------
http://wiki.processmaker.com/index.php?title=Output_Documents&printable=yes
24-09-2010
Page 6 of 8
Note that a multilingual Output Document like this can be created by first logging into ProcessMaker in English and creating the Output Document, then logging into ProcessMaker in Spanish and editing the same output document in Spanish. When Output Documents are generated while running a case, an HTML file is created based upon the Output Document's template. From that HTML file, a PDF and/or DOC file are created. (Actually the DOC file is really just HTML code inside a DOC container.) In GNU/Linux or UNIX, Output Document files are saved at:
<INSTALL-DIRECTORY>/shared/sites/<WORKSPACE>/files/<CASE-UID>/outdocs/<OUT_DOC_FILENAME>.html /<OUT_DOC_FILENAME>.pdf /<OUT_DOC_FILENAME>.doc
For example:
/opt/processmaker/shared/sites/workflow/files/a03459e1cb9824dac456780eca7b5cf6/outdocs/OpenCaseLetter.html
For example:
c:\Program Files\ProcessMaker\apps\processmaker\shared\workflow_data\files\a03459e1cb9824dac456780eca7b5cf6\outdo
http://wiki.processmaker.com/index.php?title=Output_Documents&printable=yes
24-09-2010
Page 7 of 8
Example 1: Get the UID for a specific output document for a case:
$docId='XXXXXXXXXXXXXXXXXXXXX'; $caseId = @@APPLICATION; $result = executeTrigger("SELECT * FROM APP_DOCUMENT WHERE APP_UID='$caseId' AND DOC_UID='$docId'"); if (is_array($result) and count($result) > 0) { @@appDocUid = $result['APP_DOC_UID']; }
If the process is going to be exported and imported into another ProcessMaker server, then an new UID will be assigned to the Output Document when it is imported. Therefore, the code can be made more portable by looking up the UID of the Output Document definition in the MySQL database. For instance if the title of the Output Document is "Invoice", then look up that title in the wf_<WORKSPACE>.CONTENT table. Replace the line:
$docId='XXXXXXXXXXXXXXXXXXXXX';
Example 2: This example sends the contents of an output document in an email. Output Documents which are generated in DOC format are basically just HTML code inside of a file with a ".doc" extension, so the HTML code can easily be extracted from the file and inserted into an email (as long as the recipient's email client supports HTML). First, open the process and right click on the process map and select the option Process File Manager from the dropdown menu. Go to the mailTemplates directory and create an email template with an inserted variable named @#Contents which will hold the contents of Output Document:
Dear Supervisor, Here is the output document for the case: @#Contents
Then, create a trigger to extract the contents the output document and pass them to the email so they can be inserted in the @#Contents variable in the email template. The 'Contents' variable can be passed as a key-value pair in an associative array, which is the last parameter for the PMFSendMessage() function.
http://wiki.processmaker.com/index.php?title=Output_Documents&printable=yes
24-09-2010
Page 8 of 8
$filename = 'FILENAME.doc'; //The FILENAME is set when defining the output document $case = @@APPLICATION; $contents = file_get_contents("INSTALL-DIRECTORY/shared/sites/workflow/files/$case/outdocs/$filename"); $PMFSendMessage(@@APPLICATION, '[email protected]', '[email protected]', , , 'Output Document for case', 'MyOutputDocument.html', array('Contents'=>$contents));
Replace FILENAME and INSTALL-DIRECTORY with the appropriate values and set this trigger to fire after the output document is generated. Retrieved from "http://wiki.processmaker.com/index.php/Output_Documents"
This page was last modified on 13 August 2010, at 19:33. Content is available under Sourceforge Logo.
http://wiki.processmaker.com/index.php?title=Output_Documents&printable=yes
24-09-2010