Customizing the Case Summary

From pmusers
Jump to: navigation, search

The following example shows how to customize the Case Summary in the Community Edition.


Author: Amos Batto (amos[en]processmaker[dot]com)
Tested in: PM 3.3.4 Community in Debian 9.5 with PHP 5.6.37


The Case Summary is displayed when opening a case under Home > Participated or opening a case which has been completed, canceled or paused. A custom Dynaform can be displayed in place of the standard Case Summary in the Enterprise Edition. Only users with the "Case Summary" permission are allowed to view the custom Dynaform.

UnmodifiedCaseSummary.png

In the Community Edition, there is no option to display a custom Dynaform for the Case Summary. However, the source code can be modified to display customized information in the Case Summary.

The Case Summary is generated by the code in the file workflow/engine/methods/cases/cases_Resume.php. This file in turn uses the templates provided by the following two XML files to display information about the case and its current task(s):

  • workflow/engine/xmlform/cases/cases_Resume.xml (displays the "Case Properties")
  • workflow/engine/xmlform/cases/cases_Resume_Current_Task_Title.xml (displays the "Current Task(s) Properties")

In this example, two additional fields are added in the "Case Properties" to display the username of the manager and the manager's decision, which are case variables set by users who worked on the cases. Change the contents of the file workflow/engine/xmlform/cases/cases_Resume.xml from:

<?xml version="1.0" encoding="UTF-8"?>

<dynaForm name="cases_Resume" type="xmlform" width="550px" labelWidth="150px">
  <TITLE1 type="title">
    <en><![CDATA[Case Properties]]></en>
  </TITLE1>
  <PRO_TITLE type="text" mode="view">
    <en><![CDATA[Process]]></en>
  </PRO_TITLE>
  <TITLE type="text" mode="view">
    <en><![CDATA[Case Title]]></en>
  </TITLE>
  <APP_NUMBER type="text" mode="view">
    <en><![CDATA[Case Number]]></en>
  </APP_NUMBER>
  <STATUS type="text" mode="view">
    <en><![CDATA[Case Stata]]></en>
  </STATUS>
  <APP_UID type="text" mode="view">
    <en><![CDATA[Case Uid]]></en>
  </APP_UID>
  <CREATOR type="text" mode="view">
    <en><![CDATA[Creator]]></en>
  </CREATOR>
  <CREATE_DATE type="text" mode="view">
    <en><![CDATA[Create Date]]></en>
  </CREATE_DATE>
  <UPDATE_DATE type="text" mode="view">
    <en><![CDATA[Last Update]]></en>
  </UPDATE_DATE>
  <DESCRIPTION type="text" mode="view">
    <en><![CDATA[Case Description]]></en>
  </DESCRIPTION>
</dynaForm>

To:

<?xml version="1.0" encoding="UTF-8"?>

<dynaForm name="cases_Resume" type="xmlform" width="550px" labelWidth="150px">
  <TITLE1 type="title">
    <en><![CDATA[Case Properties]]></en>
  </TITLE1>
  <PRO_TITLE type="text" mode="view">
    <en><![CDATA[Process]]></en>
  </PRO_TITLE>
  <TITLE type="text" mode="view">
    <en><![CDATA[Case Title]]></en>
  </TITLE>
  <APP_NUMBER type="text" mode="view">
    <en><![CDATA[Case Number]]></en>
  </APP_NUMBER>
  <STATUS type="text" mode="view">
    <en><![CDATA[Case Stata]]></en>
  </STATUS>
  <APP_UID type="text" mode="view">
    <en><![CDATA[Case Uid]]></en>
  </APP_UID>
  <CREATOR type="text" mode="view">
    <en><![CDATA[Creator]]></en>
  </CREATOR>
  <CREATE_DATE type="text" mode="view">
    <en><![CDATA[Create Date]]></en>
  </CREATE_DATE>
  <UPDATE_DATE type="text" mode="view">
    <en><![CDATA[Last Update]]></en>
  </UPDATE_DATE>
  <DESCRIPTION type="text" mode="view">
    <en><![CDATA[Case Description]]></en>
  </DESCRIPTION>
  <MANAGER type="text" mode="view">
    <en><![CDATA[Manager]]></en>
  </MANAGER>
  <MANAGER_DECISION type="text" mode="view">
    <en><![CDATA[Manager Decision]]></en>
  </MANAGER_DECISION>  
</dynaForm>

Now the "Manager" and "Manager Decision" fields will be displayed at the bottom of the "Case Properties" section.

In addition, the file workflow/engine/methods/cases/cases_Resume.php is modified to pass the data for these two new fields to the template files. The fields which will be inserted in the XML templates are elements in the $Fields array.

In order to pass the case variables manager and managerDecision to the template cases_Resume.xml, change the source code from:

$Fields['TAS_TITLE'] = $aTask['TAS_TITLE'];
$Fields = DateTime::convertUtcToTimeZone($Fields);

$objUser = new Users();
$oHeadPublisher = headPublisher::getSingleton();
$oHeadPublisher->addScriptFile('/jscore/cases/core/cases_Step.js');
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_Resume.xml', '', $Fields, '');

To:

$Fields['TAS_TITLE'] = $aTask['TAS_TITLE'];
$Fields = DateTime::convertUtcToTimeZone($Fields);

//pass two case variables to the template cases_Resume.php:
$Fields['MANAGER']          = isset($Fields['APP_DATA']['manager'])         ? $Fields['APP_DATA']['manager']         : '';
$Fields['MANAGER_DECISION'] = isset($Fields['APP_DATA']['managerDecision']) ? $Fields['APP_DATA']['managerDecision'] : '';

$objUser = new Users();
$oHeadPublisher = headPublisher::getSingleton();
$oHeadPublisher->addScriptFile('/jscore/cases/core/cases_Step.js');
$G_PUBLISH = new Publisher();
$G_PUBLISH->AddContent('xmlform', 'xmlform', 'cases/cases_Resume.xml', '', $Fields, '');

Now the Case Summary will display the two additional fields:

ModifiedCaseSummary.png

The Case Summary can also be displayed inside a window, by clicking on the CaseSummaryIcon.png icon in a case list or by right clicking on a case in the list and selecting Case Summary from the context menu.

UnmodifiedCaseSummaryWindow.png

In order to add two additional case variables to the Case Summary window, edit the source code in the file workflow/engine/controllers/appProxy.php. Change the code starting at line 281 from:

        $data[] = array ('label' => $labelsCaseProperties['UPDATE_DATE'],'value' => $applicationFields['UPDATE_DATE'],'section' => $labelsCaseProperties['TITLE1']);
        $data[] = array ("label" => $labelsCaseProperties["DESCRIPTION"], "value" => htmlentities($applicationFields["DESCRIPTION"], ENT_QUOTES, "UTF-8"), "section" => $labelsCaseProperties["TITLE1"]);

        // note added by krlos pacha carlos[at]colosa[dot]com
        //getting this field if it doesn't exist. Related 7994 bug
        $oTask = new \Task();

To:

        $data[] = array ('label' => $labelsCaseProperties['UPDATE_DATE'],'value' => $applicationFields['UPDATE_DATE'],'section' => $labelsCaseProperties['TITLE1']);
        $data[] = array ("label" => $labelsCaseProperties["DESCRIPTION"], "value" => htmlentities($applicationFields["DESCRIPTION"], ENT_QUOTES, "UTF-8"), "section" => $labelsCaseProperties["TITLE1"]);
        
        //insert two case variables
        $data[] = array (
           "label" => "Manager", 
           "value" => isset($applicationFields["APP_DATA"]["manager"]) ? $applicationFields["APP_DATA"]["manager"] : "", 
           "section" => $labelsCaseProperties["TITLE1"]
        );
        $data[] = array (
           "label" => "Manager Decision", 
           "value" => isset($applicationFields["APP_DATA"]["managerDecision"]) ? $applicationFields["APP_DATA"]["managerDecision"] : "", 
           "section" => $labelsCaseProperties["TITLE1"]
        );

        // note added by krlos pacha carlos[at]colosa[dot]com
        //getting this field if it doesn't exist. Related 7994 bug
        $oTask = new \Task();

After making that change, the two additional fields "Manager" and "Manager Decision" will be added to the Case Summary window:

ModifiedCaseSummaryWindow.png