@@ -1126,23 +1126,16 @@ class Cases
|
||||
* @return Fields
|
||||
*/
|
||||
|
||||
public function removeCase($sAppUid)
|
||||
public function removeCase($sAppUid, $deleteDelegation = true)
|
||||
{
|
||||
try {
|
||||
$this->getExecuteTriggerProcess($sAppUid, 'DELETED');
|
||||
|
||||
$oAppDelegation = new AppDelegation();
|
||||
$oAppDocument = new AppDocument();
|
||||
|
||||
//Delete the delegations of a application
|
||||
$oCriteria2 = new Criteria('workflow');
|
||||
$oCriteria2->add(AppDelegationPeer::APP_UID, $sAppUid);
|
||||
$oDataset2 = AppDelegationPeer::doSelectRS($oCriteria2);
|
||||
$oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset2->next();
|
||||
while ($aRow2 = $oDataset2->getRow()) {
|
||||
$oAppDelegation->remove($sAppUid, $aRow2['DEL_INDEX']);
|
||||
$oDataset2->next();
|
||||
if($deleteDelegation) {
|
||||
//Delete the delegations of a application
|
||||
$this->deleteDelegation($sAppUid);
|
||||
}
|
||||
//Delete the documents assigned to a application
|
||||
$oCriteria2 = new Criteria('workflow');
|
||||
@@ -1237,6 +1230,9 @@ class Cases
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ListParticipatedLastPeer::APP_UID, $sAppUid);
|
||||
ListParticipatedLastPeer::doDelete($oCriteria);
|
||||
$oCriteria = new Criteria('workflow');
|
||||
$oCriteria->add(ListPausedPeer::APP_UID, $sAppUid);
|
||||
ListPausedPeer::doDelete($oCriteria);
|
||||
/*----------------------------------********---------------------------------*/
|
||||
return $result;
|
||||
} catch (exception $e) {
|
||||
@@ -7295,5 +7291,19 @@ class Cases
|
||||
return $processList;
|
||||
}
|
||||
|
||||
public function deleteDelegation($sAppUid)
|
||||
{
|
||||
$oAppDelegation = new AppDelegation();
|
||||
$oCriteria2 = new Criteria('workflow');
|
||||
$oCriteria2->add(AppDelegationPeer::APP_UID, $sAppUid);
|
||||
$oDataset2 = AppDelegationPeer::doSelectRS($oCriteria2);
|
||||
$oDataset2->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
$oDataset2->next();
|
||||
while ($aRow2 = $oDataset2->getRow()) {
|
||||
$oAppDelegation->remove($sAppUid, $aRow2['DEL_INDEX']);
|
||||
$oDataset2->next();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1052,5 +1052,70 @@ class Process extends BaseProcess
|
||||
}
|
||||
return $aProc;
|
||||
}
|
||||
|
||||
public function deleteProcessCases($proUid)
|
||||
{
|
||||
try {
|
||||
/*get cases by process uid*/
|
||||
$oCase = new Cases();
|
||||
$oCriteria = new Criteria( 'workflow' );
|
||||
$oCriteria->addSelectColumn( ApplicationPeer::APP_UID);
|
||||
$oCriteria->add( ApplicationPeer::PRO_UID, $proUid );
|
||||
$oDataset = ApplicationPeer::doSelectRS( $oCriteria, Propel::getDbConnection('workflow_ro') );
|
||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
||||
while ($oDataset->next()) {
|
||||
$row = $oDataset->getRow();
|
||||
$oCase->removeCase($row['APP_UID'], false);
|
||||
}
|
||||
} catch(Exception $e) {
|
||||
throw ($e);
|
||||
}
|
||||
}
|
||||
|
||||
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'])) {
|
||||
$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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,6 +80,13 @@ $oHeadPublisher->assign("arrayMenuNewOptionPlugin", $arrayMenuNewOptionPlugin);
|
||||
$oHeadPublisher->assign("arrayContextMenuOptionPlugin", $arrayContextMenuOptionPlugin);
|
||||
$oHeadPublisher->assign('extJsViewState', $oHeadPublisher->getExtJsViewState());
|
||||
|
||||
$deleteCasesFlag = false;
|
||||
global $RBAC;
|
||||
if($RBAC->userCanAccess('DELETE_PROCESS_CASES') === 1) {
|
||||
$deleteCasesFlag = true;
|
||||
}
|
||||
$oHeadPublisher->assign('deleteCasesFlag', $deleteCasesFlag);
|
||||
|
||||
$oPluginRegistry = & PMPluginRegistry::getSingleton();
|
||||
$callBackFile = $oPluginRegistry->getImportProcessCallback();
|
||||
$file = false;
|
||||
|
||||
25
workflow/engine/methods/processes/processes_DeleteCases.php
Normal file
25
workflow/engine/methods/processes/processes_DeleteCases.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
global $RBAC;
|
||||
$RBAC->requirePermissions( 'DELETE_PROCESS_CASES', 'PM_FACTORY' );
|
||||
|
||||
try {
|
||||
$uids = explode(',', $_POST['PRO_UIDS']);
|
||||
$oProcess = new Process();
|
||||
foreach ($uids as $uid) {
|
||||
$oProcess->deleteProcessCases($uid);
|
||||
}
|
||||
$oProcess->refreshUserAllCountersByProcessesGroupUid($uids);
|
||||
|
||||
$resp = new StdClass();
|
||||
$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();
|
||||
echo G::json_encode($resp);
|
||||
}
|
||||
|
||||
|
||||
@@ -360,6 +360,12 @@ Ext.onReady(function(){
|
||||
importProcessGlobal.processFileType = "pm";
|
||||
importProcess();
|
||||
}
|
||||
},{
|
||||
id: 'deleteCasesId',
|
||||
text: _('ID_DELETE_CASES'),
|
||||
iconCls: "button_menu_ext ss_sprite ss_cross",
|
||||
handler: deleteCases,
|
||||
hidden: true
|
||||
},{
|
||||
xtype: 'tbfill'
|
||||
},{
|
||||
@@ -429,6 +435,10 @@ Ext.onReady(function(){
|
||||
}
|
||||
});
|
||||
|
||||
if(deleteCasesFlag) {
|
||||
Ext.getCmp("deleteCasesId").show();
|
||||
}
|
||||
|
||||
processesGrid.store.load({params: {"function": "languagesList", "start": 0, "limit": 25}});
|
||||
processesGrid.addListener('rowcontextmenu', onMessageContextMenu,this);
|
||||
processesGrid.on('rowcontextmenu', function (grid, rowIndex, evt) {
|
||||
@@ -824,6 +834,76 @@ deleteProcess = function(){
|
||||
}
|
||||
}
|
||||
|
||||
var deleteCases = function(){
|
||||
var rows = processesGrid.getSelectionModel().getSelections(),
|
||||
totalCases = 0,
|
||||
ids = Array(),
|
||||
PRO_UIDS,
|
||||
i;
|
||||
if( rows.length > 0 ) {
|
||||
for(i=0; i<rows.length; i++){
|
||||
var numCases = rows[i].get('CASES_COUNT');
|
||||
if(numCases != 0) {
|
||||
totalCases = totalCases + parseInt(numCases);
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0; i<rows.length; i++) {
|
||||
ids[i] = rows[i].get('PRO_UID');
|
||||
}
|
||||
|
||||
PRO_UIDS = ids.join(',');
|
||||
|
||||
Ext.Msg.confirm(
|
||||
_('ID_CONFIRM'),
|
||||
_('ID_DELETE_PROCESS_CASES')+' '+totalCases+' '+_('CASES'),
|
||||
function(btn, text){
|
||||
if ( btn == 'yes' ){
|
||||
Ext.MessageBox.show({ msg: _('ID_DELETING_ELEMENTS'), wait:true,waitConfig: {interval:200} });
|
||||
Ext.Ajax.request({
|
||||
timeout: 300000,
|
||||
url: 'processes_DeleteCases',
|
||||
success: function(response) {
|
||||
Ext.MessageBox.hide();
|
||||
processesGrid.store.reload();
|
||||
result = Ext.util.JSON.decode(response.responseText);
|
||||
|
||||
if(result){
|
||||
if(!result.status){
|
||||
Ext.MessageBox.show({
|
||||
title: _('ID_ERROR'),
|
||||
msg: result.msg,
|
||||
buttons: Ext.MessageBox.OK,
|
||||
icon: Ext.MessageBox.ERROR
|
||||
});
|
||||
}
|
||||
} else {
|
||||
Ext.MessageBox.show({
|
||||
title: _('ID_ERROR'),
|
||||
msg: response.responseText,
|
||||
buttons: Ext.MessageBox.OK,
|
||||
icon: Ext.MessageBox.ERROR
|
||||
});
|
||||
}
|
||||
},
|
||||
params: {PRO_UIDS:PRO_UIDS}
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
} else {
|
||||
Ext.Msg.show({
|
||||
title: _("ID_INFORMATION"),
|
||||
msg: _('ID_NO_SELECTION_WARNING'),
|
||||
buttons: Ext.Msg.INFO,
|
||||
fn: function(){},
|
||||
animEl: 'elId',
|
||||
icon: Ext.MessageBox.INFO,
|
||||
buttons: Ext.MessageBox.OK
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function exportProcess() {
|
||||
var record = processesGrid.getSelectionModel().getSelections();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user