Merged in bugfix/PMCORE-543 (pull request #7238)

PMCORE-543

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Paula Quispe
2020-02-05 13:19:17 +00:00
committed by Julio Cesar Laura Avendaño
4 changed files with 415 additions and 121 deletions

View File

@@ -546,45 +546,36 @@ class Ajax
G::RenderPage('publish', 'extJs');
}
/**
* Cancel case from actions menu
*
* @link https://wiki.processmaker.com/3.3/Cases/Actions#Cancel
*
* @return void
*/
public function cancelCase()
{
$oCase = new Cases();
$multiple = false;
if (isset($_POST['APP_UID']) && isset($_POST['DEL_INDEX'])) {
$APP_UID = $_POST['APP_UID'];
$DEL_INDEX = $_POST['DEL_INDEX'];
$appUids = explode(',', $APP_UID);
$delIndexes = explode(',', $DEL_INDEX);
if (count($appUids) > 1 && count($delIndexes) > 1) {
$multiple = true;
try {
$appUid = !empty($_SESSION['APPLICATION']) ? $_SESSION['APPLICATION'] : '';
$index = !empty($_SESSION['INDEX']) ? $_SESSION['INDEX'] : '';
$usrUid = !empty($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : '';
$result = new stdclass();
if (!empty($appUid) && !empty($index) && !empty($usrUid)) {
$ws = new WsBase();
$response = (object)$ws->cancelCase($appUid, $index, $usrUid);
// Review if the case was cancelled, true if the case was cancelled
$result->status = ($response->status_code == 0) ? true : false;
$result->msg = $response->message;
} else {
$result->status = false;
$result->msg = G::LoadTranslation("ID_CASE_USER_INVALID_CANCEL_CASE", [$usrUid]);
}
} elseif (isset($_POST['sApplicationUID']) && isset($_POST['iIndex'])) {
$APP_UID = $_POST['sApplicationUID'];
$DEL_INDEX = $_POST['iIndex'];
} else {
$APP_UID = $_SESSION['APPLICATION'];
$DEL_INDEX = $_SESSION['INDEX'];
} catch (Exception $e) {
$result->status = false;
$result->msg = $e->getMessage();
}
// Save the note pause reason
if ($_POST['NOTE_REASON'] != '') {
require_once("classes/model/AppNotes.php");
$appNotes = new AppNotes();
$noteContent = addslashes($_POST['NOTE_REASON']);
$appNotes->postNewNote($APP_UID, $_SESSION['USER_LOGGED'], $noteContent, $_POST['NOTIFY_PAUSE']);
}
// End save
if ($multiple) {
foreach ($appUids as $i => $appUid) {
$oCase->cancelCase($appUid, $delIndexes[$i], $_SESSION['USER_LOGGED']);
}
} else {
$oCase->cancelCase($APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED']);
}
print G::json_encode($result);
}
public function getUsersToReassign()

View File

@@ -1026,81 +1026,86 @@ Ext.onReady(function(){
});
}
Actions.cancelCase = function()
{
var msgCancel = new Ext.Window({
width:500,
plain: true,
modal: true,
resizable: false,
title: _('ID_CONFIRM'),
items: [
new Ext.FormPanel({
labelAlign: 'top',
labelWidth: 75,
border: false,
frame: true,
Actions.cancelCase = function () {
var msgCancel = new Ext.Window({
width: 500,
plain: true,
modal: true,
resizable: false,
title: _('ID_CONFIRM'),
items: [
{
html: '<div align="center" style="font: 14px tahoma,arial,helvetica,sans-serif">' + _('ID_CONFIRM_CANCEL_CASE')+'? </div> <br/>'
},
{
xtype: 'textarea',
id: 'noteReason',
fieldLabel: _('ID_CASE_CANCEL_REASON'),
name: 'noteReason',
width: 450,
height: 50
},
{
id: 'notifyReason',
xtype:'checkbox',
name: 'notifyReason',
hideLabel: true,
boxLabel: _('ID_NOTIFY_USERS_CASE')
}
],
buttonAlign: 'center',
buttons: [{
text: 'Ok',
handler: function(){
if (Ext.getCmp('noteReason').getValue() != '') {
var noteReasonTxt = _('ID_CASE_CANCEL_LABEL_NOTE') + ' ' + Ext.getCmp('noteReason').getValue();
} else {
var noteReasonTxt = '';
}
var notifyReasonVal = Ext.getCmp('notifyReason').getValue() == true ? 1 : 0;
Ext.MessageBox.show({ msg: _('ID_PROCESSING'), wait:true,waitConfig: {interval:200} });
Ext.Ajax.request({
url : 'ajaxListener' ,
params : {action : 'cancelCase', NOTE_REASON: noteReasonTxt, NOTIFY_PAUSE: notifyReasonVal},
success: function ( result, request ) {
try {
parent.notify("", _("ID_CASE_CANCELLED", stringReplace("\\: ", "", _APP_NUM)));
parent.updateCasesTree();
}
catch (e) {
}
location.href = 'casesListExtJs';
},
failure: function ( result, request) {
Ext.MessageBox.alert( _('ID_FAILED'), result.responseText);
}
});
}
},{
text: _('ID_CANCEL'),
handler: function(){
msgCancel.close();
}
}]
})
]
});
msgCancel.show(this);
new Ext.FormPanel({
labelAlign: 'top',
labelWidth: 75,
border: false,
frame: true,
items: [{
html: '<div align="center" style="font: 14px tahoma,arial,helvetica,sans-serif">' + _('ID_CONFIRM_CANCEL_CASE') + '? </div> <br/>'
},
{
xtype: 'textarea',
id: 'noteReason',
fieldLabel: _('ID_CASE_CANCEL_REASON'),
name: 'noteReason',
width: 450,
height: 50
},
{
id: 'notifyReason',
xtype: 'checkbox',
name: 'notifyReason',
hideLabel: true,
boxLabel: _('ID_NOTIFY_USERS_CASE')
}],
buttonAlign: 'center',
buttons: [{
text: 'Ok',
handler: function () {
if (Ext.getCmp('noteReason').getValue() != '') {
var noteReasonTxt = _('ID_CASE_CANCEL_LABEL_NOTE') + ' ' + Ext.getCmp('noteReason').getValue();
} else {
var noteReasonTxt = '';
}
var notifyReasonVal = Ext.getCmp('notifyReason').getValue() == true ? 1 : 0;
Ext.MessageBox.show({msg: _('ID_PROCESSING'), wait: true, waitConfig: {interval: 200}});
Ext.Ajax.request({
url: 'ajaxListener',
params: {
action: 'cancelCase',
NOTE_REASON: noteReasonTxt,
NOTIFY_PAUSE: notifyReasonVal
},
success: function (result, request) {
try {
var data = Ext.util.JSON.decode(result.responseText);
if (data.status == true) {
// The case was cancelled
parent.notify('', _("ID_CASE_CANCELLED", stringReplace("\\: ", "", _APP_NUM)));
} else {
// The case wasn't cancel
parent.notify('', data.msg);
}
parent.updateCasesTree();
} catch (e) {
parent.notify('', _('ID_SOMETHING_WRONG'));
}
location.href = 'casesListExtJs';
},
failure: function (result, request) {
Ext.MessageBox.alert(_('ID_FAILED'), result.responseText);
}
});
}
}, {
text: _('ID_CANCEL'),
handler: function () {
msgCancel.close();
}
}]
})
]
});
msgCancel.show(this);
}
Actions.getUsersToReassign = function()