BUG 9607 "Need a way to disable/enable eMail notifications..." SOLVED

- New feature, Need a way to disable/enable eMaill notifications when
  a case note is created
- Solved, added checkbox for send eMail notifications or not
This commit is contained in:
Victor Saisa Lopez
2012-08-17 09:03:31 -04:00
parent 8bda7b987e
commit fa91fb5e51
2 changed files with 59 additions and 30 deletions

View File

@@ -19,10 +19,10 @@ class AppProxy extends HttpProxyController
{ {
require_once ( "classes/model/AppNotes.php" ); require_once ( "classes/model/AppNotes.php" );
$appUid = null; $appUid = null;
if (isset($httpData->appUid) && trim($httpData->appUid) != "") { if (isset($httpData->appUid) && trim($httpData->appUid) != "") {
$appUid = $httpData->appUid; $appUid = $httpData->appUid;
} }
else { else {
if (isset($_SESSION['APPLICATION'])) { if (isset($_SESSION['APPLICATION'])) {
$appUid = $_SESSION['APPLICATION']; $appUid = $_SESSION['APPLICATION'];
@@ -36,7 +36,7 @@ class AppProxy extends HttpProxyController
$usrUid = isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : ""; $usrUid = isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : "";
$appNotes = new AppNotes(); $appNotes = new AppNotes();
$response = $appNotes->getNotesList($appUid, '', $httpData->start, $httpData->limit); $response = $appNotes->getNotesList($appUid, '', $httpData->start, $httpData->limit);
return $response['array']; return $response['array'];
} }
@@ -45,16 +45,16 @@ class AppProxy extends HttpProxyController
* @param string $httpData->appUid (optional, if it is not passed try use $_SESSION['APPLICATION']) * @param string $httpData->appUid (optional, if it is not passed try use $_SESSION['APPLICATION'])
* @return array containg the case notes * @return array containg the case notes
*/ */
function postNote($httpData) function postNote($httpData)
{ {
//extract(getExtJSParams()); //extract(getExtJSParams());
if (isset($httpData->appUid) && trim($httpData->appUid) != "") { if (isset($httpData->appUid) && trim($httpData->appUid) != "") {
$appUid = $httpData->appUid; $appUid = $httpData->appUid;
} }
else { else {
$appUid = $_SESSION['APPLICATION']; $appUid = $_SESSION['APPLICATION'];
} }
if (!isset($appUid)) { if (!isset($appUid)) {
throw new Exception('Can\'t resolve the Apllication ID for this request.'); throw new Exception('Can\'t resolve the Apllication ID for this request.');
} }
@@ -67,10 +67,10 @@ class AppProxy extends HttpProxyController
$result = $appNotes->postNewNote($appUid, $usrUid, $noteContent, false); $result = $appNotes->postNewNote($appUid, $usrUid, $noteContent, false);
// Disabling the controller response because we handle a special behavior //Disabling the controller response because we handle a special behavior
$this->setSendResponse(false); $this->setSendResponse(false);
//send the response to client //Send the response to client
@ini_set('implicit_flush', 1); @ini_set('implicit_flush', 1);
ob_start(); ob_start();
echo G::json_encode($result); echo G::json_encode($result);
@@ -79,26 +79,31 @@ class AppProxy extends HttpProxyController
@ob_end_flush(); @ob_end_flush();
ob_implicit_flush(1); ob_implicit_flush(1);
//send notification in background //Send notification in background
$noteRecipientsList = array(); if (intval($httpData->swSendMail) == 1) {
G::LoadClass('case'); G::LoadClass("case");
$oCase = new Cases();
$p = $oCase->getUsersParticipatedInCase($appUid); $oCase = new Cases();
foreach($p['array'] as $key => $userParticipated){
$noteRecipientsList[] = $key; $p = $oCase->getUsersParticipatedInCase($appUid);
$noteRecipientsList = array();
foreach ($p["array"] as $key => $userParticipated) {
$noteRecipientsList[] = $key;
}
$noteRecipients = implode(",", $noteRecipientsList);
$noteContent = stripslashes($noteContent);
$appNotes->sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients);
} }
$noteRecipients = implode(",", $noteRecipientsList);
$noteContent = stripslashes($noteContent);
$appNotes->sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients);
} }
/** /**
* request to open the case summary * request to open the case summary
* @param string $httpData->appUid * @param string $httpData->appUid
* @param string $httpData->delIndex * @param string $httpData->delIndex
* @return object bool $result->succes, string $result->message(is an exception was thrown), string $result->dynUid * @return object bool $result->succes, string $result->message(is an exception was thrown), string $result->dynUid
*/ */
function requestOpenSummary($httpData) function requestOpenSummary($httpData)
{ {
@@ -125,7 +130,7 @@ class AppProxy extends HttpProxyController
$applicationFields = $case->loadCase($httpData->appUid, $httpData->delIndex); $applicationFields = $case->loadCase($httpData->appUid, $httpData->delIndex);
$process = new Process(); $process = new Process();
$processData = $process->load($applicationFields['PRO_UID']); $processData = $process->load($applicationFields['PRO_UID']);
if (isset($processData['PRO_DYNAFORMS']['PROCESS'])) { if (isset($processData['PRO_DYNAFORMS']['PROCESS'])) {
$this->dynUid = $processData['PRO_DYNAFORMS']['PROCESS']; $this->dynUid = $processData['PRO_DYNAFORMS']['PROCESS'];
} }
@@ -141,7 +146,7 @@ class AppProxy extends HttpProxyController
/** /**
* get the case summary data * get the case summary data
* @param string $httpData->appUid * @param string $httpData->appUid
* @param string $httpData->delIndex * @param string $httpData->delIndex
* @return array containg the case summary data * @return array containg the case summary data
*/ */
@@ -186,7 +191,7 @@ class AppProxy extends HttpProxyController
// note added by krlos pacha carlos[at]colosa[dot]com // note added by krlos pacha carlos[at]colosa[dot]com
//getting this field if it doesn't exist. Related 7994 bug //getting this field if it doesn't exist. Related 7994 bug
$taskData['TAS_TITLE'] = (array_key_exists('TAS_TITLE', $taskData))?$taskData['TAS_TITLE']:Content::Load("TAS_TITLE", "", $applicationFields['TAS_UID'], SYS_LANG); $taskData['TAS_TITLE'] = (array_key_exists('TAS_TITLE', $taskData))?$taskData['TAS_TITLE']:Content::Load("TAS_TITLE", "", $applicationFields['TAS_UID'], SYS_LANG);
$data[] = array('label'=>$labels['TAS_TITLE'] , 'value' => $taskData['TAS_TITLE'], 'section'=>$labels['TITLE2']); $data[] = array('label'=>$labels['TAS_TITLE'] , 'value' => $taskData['TAS_TITLE'], 'section'=>$labels['TITLE2']);
$data[] = array('label'=>$labels['CURRENT_USER'] , 'value' => $currentUser, 'section'=>$labels['TITLE2']); $data[] = array('label'=>$labels['CURRENT_USER'] , 'value' => $currentUser, 'section'=>$labels['TITLE2']);
$data[] = array('label'=>$labels['DEL_DELEGATE_DATE'] , 'value' => $applicationFields['DEL_DELEGATE_DATE'],'section'=>$labels['TITLE2']); $data[] = array('label'=>$labels['DEL_DELEGATE_DATE'] , 'value' => $applicationFields['DEL_DELEGATE_DATE'],'section'=>$labels['TITLE2']);
@@ -199,3 +204,4 @@ class AppProxy extends HttpProxyController
} }
} }

View File

@@ -5,6 +5,8 @@ var appUid;
var title; var title;
var summaryWindowOpened = false; var summaryWindowOpened = false;
var toolTipChkSendMail;
function closeCaseNotesWindow(){ function closeCaseNotesWindow(){
if(Ext.get("caseNotesWindowPanel")){ if(Ext.get("caseNotesWindowPanel")){
Ext.get("caseNotesWindowPanel").destroy(); Ext.get("caseNotesWindowPanel").destroy();
@@ -119,7 +121,7 @@ function openCaseNotesWindow(appUid1, modalSw, appTitle)
caseNotesWindow = new Ext.Window({ caseNotesWindow = new Ext.Window({
title: _('ID_CASES_NOTES'), //Title of the Window title: _('ID_CASES_NOTES'), //Title of the Window
id: 'caseNotesWindowPanel', //ID of the Window Panel id: 'caseNotesWindowPanel', //ID of the Window Panel
width:300, //Width of the Window width: 350, //Width of the Window
resizable: true, //Resize of the Window, if false - it cannot be resized resizable: true, //Resize of the Window, if false - it cannot be resized
closable: true, //Hide close button of the Window closable: true, //Hide close button of the Window
modal: modalSw, //When modal:true it make the window modal and mask everything behind it when displayed modal: modalSw, //When modal:true it make the window modal and mask everything behind it when displayed
@@ -153,7 +155,7 @@ function openCaseNotesWindow(appUid1, modalSw, appTitle)
xtype : 'textarea', xtype : 'textarea',
id : 'caseNoteText', id : 'caseNoteText',
name : 'caseNoteText', name : 'caseNoteText',
width : 280, width : 330,
grow : true, grow : true,
height : 40, height : 40,
growMin: 40, growMin: 40,
@@ -171,6 +173,13 @@ function openCaseNotesWindow(appUid1, modalSw, appTitle)
], ],
rowtbar: [ rowtbar: [
[ [
{
xtype: "checkbox",
id: "chkSendMail",
name: "chkSendMail",
checked: true,
boxLabel: _("ID_CASE_NOTES_LABEL_SEND")
},
'->', '->',
'<span id="countChar">500</span>', '<span id="countChar">500</span>',
' ', ' ',
@@ -220,6 +229,14 @@ function openCaseNotesWindow(appUid1, modalSw, appTitle)
} }
}); });
toolTipChkSendMail = new Ext.ToolTip({
dismissDelay: 3000, //auto hide after 3 seconds
title: _("ID_CASE_NOTES_HINT_SEND"),
//html "",
//text: "",
width: 200
});
newNoteAreaActive = false; newNoteAreaActive = false;
caseNotesWindow.show(); caseNotesWindow.show();
newNoteHandler(); newNoteHandler();
@@ -253,17 +270,21 @@ function newNoteHandler()
Ext.getCmp('addCancelBtn').setIcon('/images/comment_add.gif'); Ext.getCmp('addCancelBtn').setIcon('/images/comment_add.gif');
caseNotesWindow.getTopToolbar().hide(); caseNotesWindow.getTopToolbar().hide();
Ext.getCmp('sendBtn').hide(); Ext.getCmp("chkSendMail").hide();
Ext.getCmp("sendBtn").hide();
document.getElementById('countChar').style.display = 'none'; document.getElementById('countChar').style.display = 'none';
caseNotesWindow.doLayout(); caseNotesWindow.doLayout();
} }
else { else {
toolTipChkSendMail.initTarget("chkSendMail");
Ext.getCmp('addCancelBtn').setText(''); Ext.getCmp('addCancelBtn').setText('');
Ext.getCmp('addCancelBtn').setTooltip({title: _('ID_CASES_NOTES_CANCEL')}); Ext.getCmp('addCancelBtn').setTooltip({title: _('ID_CASES_NOTES_CANCEL')});
Ext.getCmp('addCancelBtn').setIcon('/images/cancel.png'); Ext.getCmp('addCancelBtn').setIcon('/images/cancel.png');
caseNotesWindow.getTopToolbar().show(); caseNotesWindow.getTopToolbar().show();
Ext.getCmp('sendBtn').show(); Ext.getCmp("chkSendMail").show();
Ext.getCmp("sendBtn").show();
document.getElementById('countChar').style.display = 'block'; document.getElementById('countChar').style.display = 'block';
Ext.getCmp('caseNoteText').focus(); Ext.getCmp('caseNoteText').focus();
Ext.getCmp('caseNoteText').reset(); Ext.getCmp('caseNoteText').reset();
@@ -290,8 +311,9 @@ function sendNote()
Ext.Ajax.request({ Ext.Ajax.request({
url : '../appProxy/postNote' , url : '../appProxy/postNote' ,
params : { params : {
appUid : appUid, appUid: appUid,
noteText: noteText noteText: noteText,
swSendMail: (Ext.getCmp("chkSendMail").checked == true)? 1 : 0
}, },
success: function ( result, request ) { success: function ( result, request ) {
var data = Ext.util.JSON.decode(result.responseText); var data = Ext.util.JSON.decode(result.responseText);
@@ -427,7 +449,7 @@ var openSummaryWindow = function(appUid, delIndex)
summaryWindowOpened = false; summaryWindowOpened = false;
}, },
failure: function (result, request) { failure: function (result, request) {
summaryWindowOpened = false; summaryWindowOpened = false;
} }
}); });
} }
@@ -463,3 +485,4 @@ Ext.Panel.prototype.onRender = function(ct, position) {
} }
} }
} }