From c921867292a8c715d5495f9cb7cf32f6bb428c41 Mon Sep 17 00:00:00 2001 From: Brayan Osmar Pereyra Suxo Date: Wed, 25 Jul 2012 16:54:54 -0400 Subject: [PATCH] BUG 4763 Add notes when pause or cancel case SOLVED - I add field textarea for comment the pause or cancel - I add field checkbox for notify to case users the pause or cancel --- .../engine/methods/cases/ajaxListener.php | 18 +++ workflow/engine/methods/cases/cases_Ajax.php | 9 ++ workflow/engine/templates/cases/casesList.js | 122 +++++++++++++----- workflow/engine/templates/cases/open.js | 122 ++++++++++++++---- 4 files changed, 218 insertions(+), 53 deletions(-) diff --git a/workflow/engine/methods/cases/ajaxListener.php b/workflow/engine/methods/cases/ajaxListener.php index d6f08923a..8c24e86cb 100755 --- a/workflow/engine/methods/cases/ajaxListener.php +++ b/workflow/engine/methods/cases/ajaxListener.php @@ -440,6 +440,15 @@ class Ajax $DEL_INDEX = $_SESSION['INDEX']; } + // 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']); @@ -497,6 +506,15 @@ class Ajax $DEL_INDEX = $_SESSION['INDEX']; } + // Save the note pause reason + if ($_REQUEST['NOTE_REASON'] != '') { + require_once ( "classes/model/AppNotes.php" ); + $appNotes = new AppNotes(); + $noteContent = addslashes($_REQUEST['NOTE_REASON']); + $appNotes->postNewNote($APP_UID, $_SESSION['USER_LOGGED'], $noteContent, $_REQUEST['NOTIFY_PAUSE']); + } + // End save + $oCase->pauseCase($APP_UID, $DEL_INDEX, $_SESSION['USER_LOGGED'], $unpauseDate); $app = new Application(); $caseData = $app->load($APP_UID); diff --git a/workflow/engine/methods/cases/cases_Ajax.php b/workflow/engine/methods/cases/cases_Ajax.php index 1d0c1e052..31ad2044a 100755 --- a/workflow/engine/methods/cases/cases_Ajax.php +++ b/workflow/engine/methods/cases/cases_Ajax.php @@ -401,6 +401,15 @@ switch (($_POST['action'])?$_POST['action']:$_REQUEST['action']) { G::RenderPage('publish', 'raw'); break; case 'pauseCase': + // Save the note pause reason + if ($_POST['NOTE_REASON'] != '') { + require_once ( "classes/model/AppNotes.php" ); + $appNotes = new AppNotes(); + $noteContent = addslashes($_POST['NOTE_REASON']); + $result = $appNotes->postNewNote($_POST['APP_UID'], $_SESSION['USER_LOGGED'], $noteContent, $_POST['NOTIFY_PAUSE']); + } + // End save + $unpauseDate = $_POST['unpausedate']; $oCase = new Cases(); if (isset($_POST['APP_UID']) && isset($_POST['DEL_INDEX'])) { diff --git a/workflow/engine/templates/cases/casesList.js b/workflow/engine/templates/cases/casesList.js index 98b3caf8d..1b2fbb2a7 100644 --- a/workflow/engine/templates/cases/casesList.js +++ b/workflow/engine/templates/cases/casesList.js @@ -177,38 +177,100 @@ function deleteCase() { function pauseCase(date){ rowModel = grid.getSelectionModel().getSelected(); - unpauseDate = date.format('Y-m-d'); - Ext.Msg.confirm( - _('ID_CONFIRM'), - _('ID_PAUSE_CASE_TO_DATE') +' '+date.format('M j, Y')+'?', - function(btn, text){ - if ( btn == 'yes' ) { - Ext.MessageBox.show({ msg: _('ID_PROCESSING'), wait:true,waitConfig: {interval:200} }); - Ext.Ajax.request({ - url: 'cases_Ajax', - success: function(response) { - try { - parent.updateCasesView(); - } - catch (e) { - // Nothing to do - } - Ext.MessageBox.hide(); - try { - parent.updateCasesTree(); - } - catch (e) { - // Nothing to do - } - Ext.MessageBox.hide(); - }, - params: {action:'pauseCase', unpausedate:unpauseDate, APP_UID:rowModel.data.APP_UID, DEL_INDEX: rowModel.data.DEL_INDEX} - }); + if(rowModel) { + unpauseDate = date.format('Y-m-d'); + var msgPause = new Ext.Window({ + //layout:'fit', + width:500, + plain: true, + modal: true, + title: _('ID_CONFIRM'), - } - } - ); + items: [ + new Ext.FormPanel({ + labelAlign: 'top', + labelWidth: 75, + border: false, + frame: true, + items: [ + { + html: '
' + _('ID_PAUSE_CASE_TO_DATE') +' '+date.format('M j, Y')+'?

' + }, + { + xtype: 'textarea', + id: 'noteReason', + fieldLabel: _('ID_CASE_PAUSE_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_PAUSE_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: 'cases_Ajax', + success: function(response) { + try { + parent.updateCasesView(); + } + catch (e) { + // Nothing to do + } + Ext.MessageBox.hide(); + try { + parent.updateCasesTree(); + } + catch (e) { + // Nothing to do + } + Ext.MessageBox.hide(); + msgPause.close(); + }, + params: {action:'pauseCase', unpausedate:unpauseDate, APP_UID:rowModel.data.APP_UID, DEL_INDEX: rowModel.data.DEL_INDEX, NOTE_REASON: noteReasonTxt, NOTIFY_PAUSE: notifyReasonVal} + }); + } + },{ + text: 'Cancel', //COCHATRA + handler: function(){ + msgPause.close(); + } + }] + }) + ] + }); + msgPause.show(this); + + } else { + Ext.Msg.show({ + title:'', + msg: _('ID_NO_SELECTION_WARNING'), + buttons: Ext.Msg.INFO, + fn: function(){}, + animEl: 'elId', + icon: Ext.MessageBox.INFO, + buttons: Ext.MessageBox.OK + }); + } } diff --git a/workflow/engine/templates/cases/open.js b/workflow/engine/templates/cases/open.js index 17ee601a8..c186359b4 100755 --- a/workflow/engine/templates/cases/open.js +++ b/workflow/engine/templates/cases/open.js @@ -465,23 +465,77 @@ Ext.onReady(function(){ Actions.cancelCase = function() { - PMExt.confirm(_('ID_CONFIRM'), _('ID_CONFIRM_CANCEL_CASE'), function(){ - Ext.Ajax.request({ - url : 'ajaxListener' , - params : {action : 'cancelCase'}, - success: function ( result, request ) { - try { - parent.notify('', 'The case ' + parent._CASE_TITLE + ' was cancelled!'); - } - catch (e) { - } - location.href = 'casesListExtJs'; - }, - failure: function ( result, request) { - Ext.MessageBox.alert('Failed', result.responseText); - } - }); + var msgCancel = new Ext.Window({ + width:500, + plain: true, + modal: true, + title: _('ID_CONFIRM'), + items: [ + new Ext.FormPanel({ + labelAlign: 'top', + labelWidth: 75, + border: false, + frame: true, + items: [ + { + html: '
' + _('ID_CONFIRM_CANCEL_CASE')+'?

' + }, + { + 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('', 'The case ' + parent._CASE_TITLE + ' was cancelled!'); + } + catch (e) { + } + location.href = 'casesListExtJs'; + }, + failure: function ( result, request) { + Ext.MessageBox.alert('Failed', result.responseText); + } + }); + } + },{ + text: 'Cancel', + handler: function(){ + msgCancel.close(); + } + }] + }) + ] }); + msgCancel.show(this); } Actions.getUsersToReassign = function() @@ -602,10 +656,11 @@ Ext.onReady(function(){ var fieldset = { xtype : 'fieldset', - autoHeight : true, + labelWidth: 150, + //autoHeight : true, defaults : { width : 170, - xtype:'label', + xtype:'label', labelStyle : 'padding: 0px;', style: 'font-weight: bold' }, @@ -620,7 +675,21 @@ Ext.onReady(function(){ allowBlank: false, value: filterDate, minValue: filterDate - }) + }), + { + xtype: 'textarea', + id: 'noteReason', + fieldLabel: _('ID_CASE_PAUSE_REASON'), + name: 'noteReason', + width: 170, + height: 50 + }, + { + id: 'notifyReason', + xtype:'checkbox', + name: 'notifyReason', + fieldLabel: _('ID_NOTIFY_USERS_CASE'), + } ], buttons : [ { @@ -640,7 +709,7 @@ Ext.onReady(function(){ var frm = new Ext.FormPanel( { id: 'unpauseFrm', labelAlign : 'right', - bodyStyle : 'padding:5px 5px 0', + //bodyStyle : 'padding:5px 5px 0', width : 250, items : [fieldset] }); @@ -648,8 +717,8 @@ Ext.onReady(function(){ var win = new Ext.Window({ title: 'Pause Case', - width: 340, - height: 170, + width: 370, + height: 230, layout:'fit', autoScroll:true, modal: true, @@ -661,6 +730,13 @@ Ext.onReady(function(){ Actions.pauseCase = function() { + if (Ext.getCmp('noteReason').getValue() != '') { + var noteReasonTxt = _('ID_CASE_PAUSE_LABEL_NOTE') + ' ' + Ext.getCmp('noteReason').getValue(); + } else { + var noteReasonTxt = ''; + } + var notifyReasonVal = Ext.getCmp('notifyReason').getValue() == true ? 1 : 0; + var paramsNote = '&NOTE_REASON=' + noteReasonTxt + '&NOTIFY_PAUSE=' + notifyReasonVal; var unpauseDate = Ext.getCmp('unpauseDate').getValue(); if( unpauseDate == '') { @@ -672,7 +748,7 @@ Ext.onReady(function(){ unpauseDate = unpauseDate.format('Y-m-d'); Ext.getCmp('unpauseFrm').getForm().submit({ - url:'ajaxListener?action=pauseCase&unpauseDate=' + unpauseDate, + url:'ajaxListener?action=pauseCase&unpauseDate=' + unpauseDate + paramsNote, waitMsg:'Pausing Case '+parent._CASE_TITLE+'...', timeout : 36000, success : function(res, req) {