This commit is contained in:
Paula Quispe
2019-08-23 08:32:18 -04:00
parent 6aab41abc2
commit 0e698e5c98
2 changed files with 31 additions and 71 deletions

View File

@@ -956,52 +956,6 @@ class Process extends BaseProcess
} }
} }
public function refreshUserAllCountersByProcessesGroupUid($proUidArray)
{
$aTypes = array(
'to_do',
'draft',
'cancelled',
'sent',
'paused',
'completed',
'selfservice'
);
$usersArray = array();
$users = new Users();
$oCase = new Cases();
$oCriteria = new Criteria();
$oCriteria->addSelectColumn(AppDelegationPeer::APP_UID);
$oCriteria->addSelectColumn(AppDelegationPeer::USR_UID);
$oCriteria->setDistinct();
$oCriteria->add(AppDelegationPeer::PRO_UID, $proUidArray, Criteria::IN);
$oRuleSet = AppDelegationPeer::doSelectRS($oCriteria);
$oRuleSet->setFetchmode(ResultSet::FETCHMODE_ASSOC);
while ($oRuleSet->next()) {
$row = $oRuleSet->getRow();
if (isset($row['USR_UID']) && $row['USR_UID'] != '') {
$usersArray[$row['USR_UID']] = $row['USR_UID'];
}
$oCase->deleteDelegation($row['APP_UID']);
}
foreach ($usersArray as $value) {
$oAppCache = new AppCacheView();
$aCount = $oAppCache->getAllCounters($aTypes, $value);
$newData = array(
'USR_UID' => $value,
'USR_TOTAL_INBOX' => $aCount['to_do'],
'USR_TOTAL_DRAFT' => $aCount['draft'],
'USR_TOTAL_CANCELLED' => $aCount['cancelled'],
'USR_TOTAL_PARTICIPATED' => $aCount['sent'],
'USR_TOTAL_PAUSED' => $aCount['paused'],
'USR_TOTAL_COMPLETED' => $aCount['completed'],
'USR_TOTAL_UNASSIGNED' => $aCount['selfservice']
);
$users->update($newData);
}
}
/** /**
* Load a process object by PRO_ID * Load a process object by PRO_ID
* *

View File

@@ -1,25 +1,31 @@
<?php <?php
global $RBAC; /**
$RBAC->requirePermissions( 'PM_DELETE_PROCESS_CASES', 'PM_FACTORY' ); * processes_DeleteCases.php
$resp = new StdClass(); *
try { * Deleting all Cases of a Process
$uids = explode(',', $_POST['PRO_UIDS']); *
$oProcess = new Process(); * @link https://wiki.processmaker.com/3.2/Processes#Deleting_all_Cases_of_a_Process
foreach ($uids as $uid) { */
$oProcess->deleteProcessCases($uid);
} global $RBAC;
$oProcess->refreshUserAllCountersByProcessesGroupUid($uids); $RBAC->requirePermissions('PM_DELETE_PROCESS_CASES', 'PM_FACTORY');
$resp = new stdClass();
$resp->status = true; try {
$resp->msg = G::LoadTranslation('ID_ALL_RECORDS_DELETED_SUCESSFULLY'); $uids = explode(',', $_POST['PRO_UIDS']);
$process = new Process();
echo G::json_encode($resp); foreach ($uids as $uid) {
$process->deleteProcessCases($uid);
} catch (Exception $e) { }
$resp->status = false;
$resp->msg = $e->getMessage(); $resp->status = true;
$resp->trace = $e->getTraceAsString(); $resp->msg = G::LoadTranslation('ID_ALL_RECORDS_DELETED_SUCESSFULLY');
echo G::json_encode($resp);
} echo G::json_encode($resp);
} catch (Exception $e) {
$resp->status = false;
$resp->msg = $e->getMessage();
$resp->trace = $e->getTraceAsString();
echo G::json_encode($resp);
}