diff --git a/workflow/engine/controllers/appProxy.php b/workflow/engine/controllers/appProxy.php index 478e0bde2..4d15d05e9 100644 --- a/workflow/engine/controllers/appProxy.php +++ b/workflow/engine/controllers/appProxy.php @@ -8,6 +8,97 @@ class AppProxy extends HttpProxyController { + /** + * Get Notes List + * @param int $httpData->start + * @param int $httpData->limit + * @param string $httpData->appUid (optionalif it is not passed try use $_SESSION['APPLICATION']) + * @return array containg the case notes + */ + function getNotesList($httpData) + { + require_once ( "classes/model/AppNotes.php" ); + $appUid = null; + + if (isset($httpData->appUid) && trim($httpData->appUid) != "") { + $appUid = $httpData->appUid; + } + else { + if (isset($_SESSION['APPLICATION'])) { + $appUid = $_SESSION['APPLICATION']; + } + } + + if (!isset($appUid)) { + throw new Exception('Can\'t resolve the Apllication ID for this request.'); + } + + $usrUid = isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : ""; + $appNotes = new AppNotes(); + $response = $appNotes->getNotesList($appUid, $usrUid, $httpData->start, $httpData->limit); + + return $response['array']; + } + + /** + * post Note Action + * @param string $httpData->appUid (optional, if it is not passed try use $_SESSION['APPLICATION']) + * @return array containg the case notes + */ + function postNote($httpData) + { + //extract(getExtJSParams()); + if (isset($httpData->appUid) && trim($httpData->appUid) != "") { + $appUid = $httpData->appUid; + } + else { + $appUid = $_SESSION['APPLICATION']; + } + + if (!isset($appUid)) { + throw new Exception('Can\'t resolve the Apllication ID for this request.'); + } + + $usrUid = (isset($_SESSION['USER_LOGGED'])) ? $_SESSION['USER_LOGGED'] : ""; + require_once ( "classes/model/AppNotes.php" ); + + $appNotes = new AppNotes(); + $noteContent = addslashes($httpData->noteText); + + $result = $appNotes->postNewNote($appUid, $usrUid, $noteContent, false); + + // Disabling the controller response because we handle a special behavior + $this->setSendResponse(false); + + //send the response to client + @ini_set('implicit_flush', 1); + ob_start(); + echo G::json_encode($result); + @ob_flush(); + @flush(); + @ob_end_flush(); + ob_implicit_flush(1); + + //send notification in background + $noteRecipientsList = array(); + G::LoadClass('case'); + $oCase = new Cases(); + + $p = $oCase->getUsersParticipatedInCase($appUid); + foreach($p['array'] as $key => $userParticipated){ + $noteRecipientsList[] = $key; + } + $noteRecipients = implode(",", $noteRecipientsList); + + $appNotes->sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients); + } + + /** + * request to open the case summary + * @param string $httpData->appUid + * @param string $httpData->delIndex + * @return object bool $result->succes, string $result->message(is an exception was thrown), string $result->dynUid + */ function requestOpenSummary($httpData) { global $RBAC; @@ -42,6 +133,12 @@ class AppProxy extends HttpProxyController $_SESSION['_processData'] = $processData; } + /** + * get the case summary data + * @param string $httpData->appUid + * @param string $httpData->delIndex + * @return array containg the case summary data + */ function getSummary($httpData) { $labels = array(); diff --git a/workflow/engine/controllers/caseProxy.php b/workflow/engine/controllers/caseProxy.php deleted file mode 100755 index 155a7ef7b..000000000 --- a/workflow/engine/controllers/caseProxy.php +++ /dev/null @@ -1,100 +0,0 @@ -start - * @param int $httpData->limit - * @param string $httpData->appUid (optionalif it is not passed try use $_SESSION['APPLICATION']) - * @return array containg the case notes - */ - function getNotesList($httpData) - { - require_once ( "classes/model/AppNotes.php" ); - $appUid = null; - - if (isset($httpData->appUid) && trim($httpData->appUid) != "") { - $appUid = $httpData->appUid; - } - else { - if (isset($_SESSION['APPLICATION'])) { - $appUid = $_SESSION['APPLICATION']; - } - } - - if (!isset($appUid)) { - throw new Exception('Can\'t resolve the Apllication ID for this request.'); - } - - $usrUid = isset($_SESSION['USER_LOGGED']) ? $_SESSION['USER_LOGGED'] : ""; - $appNotes = new AppNotes(); - $response = $appNotes->getNotesList($appUid, $usrUid, $httpData->start, $httpData->limit); - - return $response['array']; - } - - function postNote($httpData) - { - //extract(getExtJSParams()); - if (isset($httpData->appUid) && trim($httpData->appUid) != "") { - $appUid = $httpData->appUid; - } - else { - $appUid = $_SESSION['APPLICATION']; - } - - if (!isset($appUid)) { - throw new Exception('Can\'t resolve the Apllication ID for this request.'); - } - - $usrUid = (isset($_SESSION['USER_LOGGED'])) ? $_SESSION['USER_LOGGED'] : ""; - require_once ( "classes/model/AppNotes.php" ); - - $appNotes = new AppNotes(); - $noteContent = addslashes($httpData->noteText); - - $result = $appNotes->postNewNote($appUid, $usrUid, $noteContent, false); - - // Disabling the controller response because we handle a special behavior - $this->setSendResponse(false); - - //send the response to client - @ini_set('implicit_flush', 1); - ob_start(); - echo G::json_encode($result); - @ob_flush(); - @flush(); - @ob_end_flush(); - ob_implicit_flush(1); - - //send notification in background - $noteRecipientsList = array(); - G::LoadClass('case'); - $oCase = new Cases(); - - $p = $oCase->getUsersParticipatedInCase($appUid); - foreach($p['array'] as $key => $userParticipated){ - $noteRecipientsList[] = $key; - } - $noteRecipients = implode(",", $noteRecipientsList); - - $appNotes->sendNoteNotification($appUid, $usrUid, $noteContent, $noteRecipients); - } - -} \ No newline at end of file diff --git a/workflow/engine/templates/app/main.js b/workflow/engine/templates/app/main.js index 92ee0f9e5..c26f393fa 100644 --- a/workflow/engine/templates/app/main.js +++ b/workflow/engine/templates/app/main.js @@ -13,7 +13,7 @@ function openCaseNotesWindow(appUid,modalSw){ var loadSize=10; var storeNotes = new Ext.data.JsonStore({ - url : '../caseProxy/getNotesList?appUid='+appUid, + url : '../appProxy/getNotesList?appUid='+appUid, root: 'notes', totalProperty: 'totalCount', fields: ['USR_USERNAME','USR_FIRSTNAME','USR_LASTNAME','USR_FULL_NAME','NOTE_DATE','NOTE_CONTENT'], @@ -219,7 +219,7 @@ caseNotesWindow = new Ext.Window({ Ext.getCmp('caseNoteText').reset(); statusBarMessage( _('ID_CASES_NOTE_POSTING'), true); Ext.Ajax.request({ - url : '../caseProxy/postNote' , + url : '../appProxy/postNote' , params : { appUid:appUid, noteText:noteText