Let's say you want to generate report for Process A,
1. Create another process, with Start Timer event consisting of a single Task named "Generate Report".
2. Configure the start timer to start every day on a particular time of your choice.
3. Create a trigger with the following code:
Code: Select all$date = date('Y-m-d', strtotime("now"));
$prev = date('Y-m-d', strtotime("-1 day"));
$pro ='xxxxxxxxxxxxxxxxxxxx'; //Replace with Id of Process A
$res = executeQuery("select USR_UID, TAS_UID, APP_UID, DEL_THREAD_STATUS from APP_DELEGATION
where PRO_UID='$pro' and DEL_DELEGATE_DATE < '$date' and DEL_DELEGATE_DATE > '$prev' ");
@=info = array(); //create a grid Variable @=info
$i=1;
if(is_array($res))
{
foreach($res as $row)
{
$user = userInfo($row['USR_UID']);
@@name = $user['firstname'] .' '. $user['lastname'];
$t = new Task();
$aTask = $t->Load($row['TAS_UID']);
@@taskTitle = $aTask["TAS_TITLE"];
//Add variables to store other info
@=info[$i] = array(
'firstName' => $name,
'lastName' => $taskTitle,
'status' => $row['DEL_THREAD_STATUS']
);
$i = $i+1;
}
}
4. Create an output document, which displays the information stored in grid.
5. Now create another trigger to fire after the first one which generates the output document and sends it via email:
Code: Select all$outDocId = 'xxxxxxxxxxxxxxxxxxxxxxxx'; //Replace with your Output Document UID
PMFGenerateOutputDocument($outDocId);
//retrieve info from the database about the generated output document file
$query = "SELECT APP_DOC_UID FROM APP_DOCUMENT WHERE APP_UID='$caseId' AND
DOC_UID='$outDocId' AND APP_DOC_STATUS='ACTIVE'";
$result = executeQuery($query);
if (!is_array($result) or count($result) == 0) {
die("Error: Unable to find generated Output Document in database.");
}
$d = new AppDocument();
$aFile = $d->Load( $result[1]['APP_DOC_UID'] );
//change from 'http://' to 'https://' if using SSL
//change 'pdf' to 'doc' for MS Word file
@@outDocUrl = 'http://' . $_SERVER['SERVER_NAME'] .
// ':' . $_SERVER['SERVER_PORT'] . //uncomment if needing a port number
'/sys'. @@SYS_SYS . '/en/neoclassic/cases/cases_ShowOutputDocument?a=' .
$aFile['APP_DOC_UID'] . '&v='. $aFile['DOC_VERSION'] . '&ext=pdf';
6. In the above trigger add PMFSendMessage() to send an email which contains the link to the output document generated. For this create an email template with @@outDocUrl variable which contains the link to the generated document.
I haven't tested the above code, but I hope you get the idea.
One more thing, configure
timereventcron.php to run everyday, so that the Start Timer event is initiated properly.