Ironbot, You will need to create a separate process that periodically executes a trigger like this:
SendEmailIfTaskNotCompleted.png (15.99 KiB) Viewed 6835 times
1. Set the intermediate timer event to periodically execute every 20 minutes.
2. Then create a email template file named "overdueCase.html" with the following content:
Code: Select allDear @#assignedUser,
The following case which is assigned to you is overdue:
Case No: @#caseNo
Case Title: @#caseTitle
Case Status: @#caseStatus
Current Task: @#taskName
When Assigned: @#taskAssigned
When Due: @#taskDue
Case Created By: @#caseCreatedBy
Case Start Date: @#caseStartDate
Case Last Updated: @#caseUpdatedDate
Link: @#caseLink
Please open the case and finish the task.
3. Then, create the following trigger in the process:
Code: Select all//find the task ID by running a case in the other process and look at the TASK system variable:
$taskId = 'XXXXXXXXXXXXXXXXXXXXXXX';
//set to the same email address used in Admin > Settings > Email Servers:
$emailFrom = 'admin@example.com';
$g = new G();
$now = date('Y-m-d H:i:s');
$query= "SELECT * FROM APP_CACHE_VIEW WHERE TAS_UID='$taskId' AND
(APP_STATUS='TO_DO' OR APP_STATUS='DRAFT') AND DEL_THREAD_STATUS='OPEN' AND
'$now' > DEL_TASK_DUE_DATE";
$aCases = executeQuery($query);
if (!is_array($aCases)) {
die("Error: Bad Query: $query\n");
}
foreach ($aCases as $aCase) {
$c = new Cases();
$aCaseInfo = $c->loadCase($aCase['APP_UID'], $aCase['DEL_INDEX']);
$aData = array(
'caseNo' => $aCase['APP_NUMBER'],
'caseTitle' => $aCase['APP_TITLE'],
'caseStatus' => $aCase['APP_STATUS'],
'taskName' => $aCase['APP_TASK_TITLE'],
'taskAssignedDate' => $aCase['DEL_DELEGATE_DATE'],
'taskDueDate' => $aCase['DEL_TASK_DUE_DATE'],
'caseCreatedBy' => $aCaseInfo['CREATOR'],
'caseStartDate' => $aCaseInfo['CREATE_DATE'],
'caseUpdatedDate'=> $aCaseInfo['UPDATE_DATE'],
'caseLink' => ($g->is_https() ? "https://" : "http://") . $_SERVER['SERVER_NAME'] .
':' . $_SERVER['SERVER_PORT'] . //comment out if no port number
'/sys'.@@SYS_SYS.'/'.@@SYS_LANG.'/'.@@SYS_SKIN.'/cases/open?APP_UID=' .
$aCase['APP_UID'] . '&DEL_INDEX=' . $aCase['DEL_INDEX'] . '&action=draft'
);
$aUser = userInfo($aCase['USR_UID']);
@@mailSent = PMFSendMessage(@@APPLICATION, $emailFrom, $aUser['mail'], '', '',
'Overdue case ' . $aCase['APP_TITLE'], 'overdueCase.html', $aData);
print "\nSending email to {$aUser['mail']} for case {$aCase['APP_TITLE']}\n";
}
Set the value of the $taskId in the code and set this trigger to be executed by the script task.
4. Then start a case in this process and route it to the script task so it will run forever.
5. Then
manually execute the timereventcron.php file on your ProcessMaker server to check that this script is functioning correctly. You will have to execute it at least two times after you have an overdue case in the other process to see it work. The first time it runs, it will set the time when it will execute, so the second time it will execute.
6. Once you have verified that it works correctly without errors, then configure your ProcessMaker server to periodically execute the timereventcron.php file. See:
http://wiki.processmaker.com/3.2/Execut ... nux.2FUNIX