Files
luos/workflow/engine/methods/processes/processes_DeleteCases.php

43 lines
1.2 KiB
PHP
Raw Permalink Normal View History

2019-08-23 08:32:18 -04:00
<?php
2021-03-23 15:13:52 -04:00
use ProcessMaker\Model\Delegation;
use ProcessMaker\Model\SubProcess;
2019-08-23 08:32:18 -04:00
/**
* processes_DeleteCases.php
*
* Deleting all Cases of a Process
*
* @link https://wiki.processmaker.com/3.2/Processes#Deleting_all_Cases_of_a_Process
*/
global $RBAC;
$RBAC->requirePermissions('PM_DELETE_PROCESS_CASES', 'PM_FACTORY');
$resp = new stdClass();
try {
$uids = explode(',', $_POST['PRO_UIDS']);
$process = new Process();
foreach ($uids as $uid) {
2021-03-23 15:13:52 -04:00
$parents = SubProcess::getProParents($uid);
if (!empty($parents)) {
if (Delegation::hasActiveParentsCases($parents)) {
$resp->status = false;
$resp->msg = G::LoadTranslation('ID_CANT_DELETE_SUB_PROCESS_PARENT_HAS_ACTIVE_CASES');
echo G::json_encode($resp);
die();
}
}
2019-08-23 08:32:18 -04:00
$process->deleteProcessCases($uid);
}
$resp->status = true;
$resp->msg = G::LoadTranslation('ID_ALL_RECORDS_DELETED_SUCESSFULLY');
echo G::json_encode($resp);
} catch (Exception $e) {
$resp->status = false;
$resp->msg = $e->getMessage();
$resp->trace = $e->getTraceAsString();
echo G::json_encode($resp);
}