Unfortunately, ProcessMaker doesn't provide a way to return to the first task in a case without having a route in your process to return to the first task.
You could cancel the existing case with PMFCancelCase() and create a new case with the PMFNewCase() function in a trigger that and pass the existing variables from the old case to the new case. That is probably the best option. You probably want to set a
case label in the new case to indicate something like: "#69 Restarted #56"
Another option is to simply delete all the records for the case in the APP_CACHE_VIEW and APP_DELEGATION tables in the database except the records where the DEL_INDEX=1. Here is the trigger code:
Code: Select all$caseId = @@APPLICATION;
$sql = "DELETE FROM APP_CACHE_VIEW WHERE APP_UID='$caseId' AND DEL_INDEX<>1";
executeQuery($sql);
$sql = "DELETE FROM APP_DELEGATION WHERE APP_UID='$caseId' AND DEL_INDEX<>1";
executeQuery($sql);
$dueDate = date('Y-m-d H:i:s', strtotime('+1 day'));
$riskDate = date('Y-m-d H:i:s', strtotime('+22 hours'));
$sql = "UPDATE APP_CACHE_VIEW SET DEL_THREAD_STATUS='OPEN', DEL_FINISH_DATE=NULL,
DEL_RISK_DATE='$riskDate', DEL_TASK_DUE_DATE='$dueDate' WHERE APP_UID='$caseId' AND DEL_INDEX=1";
executeQuery($sql);
$sql = "UPDATE APP_DELEGATION SET DEL_THREAD_STATUS='OPEN', DEL_FINISH_DATE=NULL,
DEL_RISK_DATE='$riskDate', DEL_TASK_DUE_DATE='$dueDate', APP_STATUS='TO_DO' WHERE APP_UID='$caseId' AND DEL_INDEX=1";
executeQuery($sql);
$sql = "UPDATE APPLICATION SET APP_STATUS='TO_DO' WHERE APP_UID='$caseId' ";
executeQuery($sql);
This is definitely not the recommended option, since it will leave orphaned records in APP_HISTORY, APP_DOCUMENT, etc. which refer to tasks that don't exist in the database and I haven't tested it, so use it at your own risk.
As for altering the cancel case dialog box, you can alter the cancelCase() function defined on line 896 in workflow/engine/templates/cases/open.js
and you can alter the cancelCase() function defined on line 533 in workflow/engine/methods/cases/ajaxListener.php
Good luck.